<?php
namespace App\Amadeus\FileParser; class Line_MFT extends \App\Amadeus\FileParser\LineAbstract { protected $structure = [ ['name'=> 'MSGTAG', 'val' => 'MFT', 'type' => 'AN', 'req' => 'M', 'len' => 3,], ['name'=> 'TOUR', 'type' => 'AN', 'req' => 'M', 'len_min' => 1, 'len_max' => 127,], ['name'=> 'DELIM', 'val' => ';', 'type' => 'AN', 'len' => 1,], ['name'=> 'LINEASS', 'val' => 'L', 'type' => 'ASSOC:loose',], ['name'=> 'DELIM', 'val' => ';', 'type' => 'AN', 'len' => 1,], ['name'=> 'PSGASS', 'val' => 'P', 'type' => 'ASSOC:loose',], ]; protected $structure_post01 = [ ['name'=> 'TSMID', 'val' => ';D', 'type' => 'AN', 'len' => 2,], ['name'=> 'TSMNBR', 'type' => 'N', 'req' => 'M', 'requires' => ['TSMID',],], ]; protected $structure_post02 = [ ['name'=> 'DELIM', 'val' => ';', 'type' => 'AN', 'len' => 1,], ['name'=> 'TSMID', 'val' => 'D', 'type' => 'AN', 'len' => 1,], ['name'=> 'TSMNBR', 'type' => 'N', 'req' => 'M', 'requires' => ['TSMID',],], ]; public function parse() { if(preg_match("/;;;/", $this->content)) { $this->tree = $this->parseFromStructure(array_merge($this->structure, $this->structure_post01), $this->content); } else { $this->tree = $this->parseFromStructure(array_merge($this->structure, $this->structure_post02), $this->content); } $this->postParse(); return $this; } } 