PHP Class EDI\Reader

Show file Open project: sabas/edifact Class Usage Examples

Public Methods

Method Description
__construct ( string $url = null ) Reader constructor.
errors ( ) Get errors
getParsedFile ( ) Returns the parsed file contained within.
groupsExtract ( type $start = 'LIN', type $barrier = ['UNS'] ) : boolean/array get groups from message when last segment is unknown but you know the barrier useful for invoices by default
load ( $url ) : boolean
preValidate ( ) : boolean Do initial validation
readEdiDataValue ( array/string $filter, integer $l1, $l2 = false, boolean $required = false ) : string/null read data value from parsed EDI data
readEdiDataValueReq ( $filter, $l1, boolean $l2 = false ) : string read required value. if no found, registre error
readEdiSegmentDTM ( integer $PeriodQualifier ) : string read date from DTM segment period qualifier - codelist 2005
readGroups ( char $before, type $start, type $end, type $after ) : boolean/array get groups from message
readTDTtransportIdentification ( $transportStageQualifier ) : string read transport identification number
readUNBDateTimeOfPpreperation ( )
readUNBDateTimeOfPreperation ( ) : mixed | string get message preparation time
readUNHmessageNumber ( ) : string read message number
readUNHmessageType ( ) : string read message type
resetErrors ( ) reset errors
setParsedFile ( array $parsed_file ) : boolean
splitMultiMessage ( $ediMessage ) : array Split multi messages to separate messages

Private Methods

Method Description
unwrap ( $string ) : array unwrap string splitting rows on terminator (if not escaped)

Method Details

__construct() public method

Reader constructor.
public __construct ( string $url = null )
$url string url or path ur EDI message

errors() public method

Get errors
public errors ( )

getParsedFile() public method

Returns the parsed file contained within.
public getParsedFile ( )

groupsExtract() public method

get groups from message when last segment is unknown but you know the barrier useful for invoices by default
public groupsExtract ( type $start = 'LIN', type $barrier = ['UNS'] ) : boolean/array
$start type first segment start a new group
$barrier type barrier segment (NOT in group)
return boolean/array

load() public method

public load ( $url ) : boolean
$url string url to edi file, path to edi file or EDI message
return boolean

preValidate() public method

Do initial validation
public preValidate ( ) : boolean
return boolean

readEdiDataValue() public method

read data value from parsed EDI data
public readEdiDataValue ( array/string $filter, integer $l1, $l2 = false, boolean $required = false ) : string/null
$filter array/string
$l1 integer first level item number (start by 1)
$required boolean if required, but no exist, register error
return string/null

readEdiDataValueReq() public method

read required value. if no found, registre error
public readEdiDataValueReq ( $filter, $l1, boolean $l2 = false ) : string
$filter string|array segment filter by segment name and values
$l1
$l2 boolean
return string

readEdiSegmentDTM() public method

read date from DTM segment period qualifier - codelist 2005
public readEdiSegmentDTM ( integer $PeriodQualifier ) : string
$PeriodQualifier integer period qualifier (codelist/2005)
return string YYYY-MM-DD HH:MM:SS

readGroups() public method

get groups from message
public readGroups ( char $before, type $start, type $end, type $after ) : boolean/array
$before char segment before groups
$start type first segment of group
$end type last segment of group
$after type segment after groups
return boolean/array

readTDTtransportIdentification() public method

read transport identification number
public readTDTtransportIdentification ( $transportStageQualifier ) : string
$transportStageQualifier
return string

readUNBDateTimeOfPpreperation() public method

Deprecation:

readUNBDateTimeOfPreperation() public method

get message preparation time

readUNHmessageNumber() public method

read message number
public readUNHmessageNumber ( ) : string
return string

readUNHmessageType() public method

read message type
public readUNHmessageType ( ) : string
return string

resetErrors() public method

reset errors
public resetErrors ( )

setParsedFile() public method

public setParsedFile ( array $parsed_file ) : boolean
$parsed_file array array
return boolean

splitMultiMessage() public static method

Split multi messages to separate messages
public static splitMultiMessage ( $ediMessage ) : array
$ediMessage string
return array