<?php
namespace App\Amadeus\StructureParser\Parser; class Passengers { protected $transaction = null; protected $passengers = []; protected $CACHE = []; public function __construct($transaction) { $this->transaction = $transaction; } public function destroy() { foreach($this->CACHE as $k=>$obj){ unset($this->CACHE[$k]); } foreach($this->passengers as $idx=>$pax){ unset($this->passengers[$idx]); } $this->transaction = null; } public function setInternalCache($CACHE) { $this->CACHE = $CACHE; return $this; } public function isValid() { return true; } public function getAll() { throw new \Exception(__METHOD__." Not implemented!"); } public function getOwner() { throw new \Exception(__METHOD__." Not implemented!"); } public function getCount() { return count($this->getAll()); } protected function internal_getFreqentFlyerCards($parsedStructure, $index, $item, $I) { $FFCards = []; $rawFFCards = []; if($I['FQV']){ foreach($I['FQV'] as $FQV){ $rawFFCards[$FQV['PRIOR']][] = ['supplier' => $FQV['AIRCDE'], 'card'=>$FQV['FQTVNBR']]; } } if($I['FQR']){ foreach($I['FQR'] as $FQR){ $rawFFCards['z'][] = ['supplier' => $FQR['AIRCDE'], 'card'=>$FQR['FQTRNBR']]; } } if($I['FQS']){ foreach($I['FQS'] as $FQS){ $rawFFCards[$FQS['PRIOR']][] = ['supplier' => $FQS['AIRCDE'], 'card'=>$FQS['FQSNBR']]; } } if($I['FQU']){ foreach($I['FQU'] as $FQU){ $rawFFCards[$FQU['PRIOR']][] = ['supplier' => $FQU['AIRCDE'], 'card'=>$FQU['FQUNBR']]; } } if($rawFFCards){ ksort($rawFFCards); foreach($rawFFCards as $cards){ foreach($cards as $card){ $key = sprintf("%s.%s", $card['supplier'], $card['card']); $FFCards[$key] = $card; } } $FFCards = array_values($FFCards); } $item->FFCards = $FFCards; return $item; } protected function internal_pickOwner($passengers) { foreach($passengers as $pax) { if($pax->isOwner) { return $pax; } } return $passengers[0]; } } 