<?php
namespace App\Amadeus\FileParser; class Line_RX extends \App\Amadeus\FileParser\LineAbstract { protected $structure = [ ['name'=> 'MSGTAG', 'val' => 'RX', 'type' => 'AN', 'req' => 'M', 'len' => 2,], ['name'=> 'COPRMK', 'type' => 'AN', 'req' => 'M',], ['name'=> 'SEGASS', 'val' => ';S', 'type' => 'ASSOC',], ['name'=> 'PSGASS', 'val' => ';P', 'type' => 'ASSOC',], ]; protected function postParse() { parent::postParse(); $delim = "/P"; $offset = strrpos($this->tree['COPRMK'], $delim); if(!$this->tree['PSGASS'] && $offset!==false){ $res = $this->parseFromStructure_v2_generalAssoc( ['name'=>'PSGASS', 'val'=>preg_quote($delim, "/"), 'type'=>'ASSOC',], $this->tree['COPRMK'], $offset, [] ); if($res['value']){ $this->tree['COPRMK'] = substr($this->tree['COPRMK'], 0, $offset); $this->tree['PSGASS'] = $res['value']; } } } } 