<?php
namespace App\Amadeus\StructureParser\Structures\Train; class Document extends \App\Amadeus\StructureParser\Parser\Document { public function document() { if($this->CACHE[__METHOD__]) return $this->CACHE[__METHOD__]; $parsedStructure = $this->transaction->getParsedStructure(); $indexType = $this->transaction->getIndexType(); $index = $this->transaction->getIndex(); $U = $parsedStructure['U'][$index->segment]; if($indexType=='U' && $U['_type']=='17'){ $doc = $this->document_U_17(); if($doc){ $this->CACHE[__METHOD__] = $doc; return $doc; } } return null; } public function supplier() { if($this->CACHE[__METHOD__]) return $this->CACHE[__METHOD__]; $parsedStructure = $this->transaction->getParsedStructure(); $indexType = $this->transaction->getIndexType(); $index = $this->transaction->getIndex(); $U = $parsedStructure['U'][$index->segment]; if($indexType=='U' && $U['_type']=='17'){ $doc = $this->supplier_U_17(); if($doc){ $this->CACHE[__METHOD__] = $doc; return $doc; } } return null; } protected function document_U_17() { $parsedStructure = $this->transaction->getParsedStructure(); $index = $this->transaction->getIndex(); $U = $parsedStructure['U'][$index->segment]; $item = new \App\Amadeus\StructureParser\Types\Document(); $item->docNumber = $U['FREE_']['confirmationNumber']; $item->docNumbers[]= $U['FREE_']['confirmationNumber']; $item->createDate = $parsedStructure['D']['PNRDTE']; $item->issueDate = $parsedStructure['D']['AIRDTE']; $item->docDate = $parsedStructure['D']['AIRDTE']; $I = $parsedStructure['I'][$index->passenger]; $item->transactionCode = $this->createTransactionCodeFromAssoc($parsedStructure['AMD']['MUC']['RECLOC']['RECLOC'], $I['GCPSGR'], [$index->segment], $parsedStructure['U'], 'TTONBR'); return $item; } protected function supplier_U_17() { $parsedStructure = $this->transaction->getParsedStructure(); $index = $this->transaction->getIndex(); $U = $parsedStructure['U'][$index->segment]; $item = new \App\Amadeus\StructureParser\Types\Supplier(); $item->codeAirline = $U['FREE_']['supplierCode']; return $item; } } 