<?php
namespace App\Sabre\StructureParser\Structures\Hotel; class Supplier extends \App\Sabre\StructureParser\Structures\Base\Supplier { protected function _getData() { list(, , $transactionIndexes, ) = $this->getTransactionDetails(); if (in_array($transactionIndexes['source'], ['M3Hhl', 'M3Oths:HHL, M5->M3, M5->M1', 'M3Oths:HHL, M5->M3', ])) { return $this->_getData_M3Hhl(); } elseif (in_array($transactionIndexes['source'], ['M3Oths:HHT', 'M3Oths:HHT, M5->M3', 'M3Oths:HHT, M5->M3, M5->M1',])) { return $this->_getData_M3Oths_HHL(); } elseif (in_array($transactionIndexes['source'], ['M3Oths:HHX', 'M3Oths:HHX, M5->M3', 'M3Oths:HHX, M5->M3, M5->M1', ])) { return $this->_getData_M3Oths_HHX(); } else { throw new \Exception(sprintf("Don't know how to interpret source '%s'", $transactionIndexes['source'])); } } private function _getData_M3Hhl() { list($parsedStructure, , $transactionIndexes) = $this->getTransactionDetails(); $M3 = $parsedStructure['M3'][$transactionIndexes['km3']]; $item = new \App\Sabre\StructureParser\Types\Supplier(); $item->codeIata = $M3['M3Hhl']['IU3PRP']; $item->name = ($M3['M3Hhl']['HFN']['HFN']?:$M3['M3Hhl']['IU3ITT']); $item->accomodation_chainCode = $M3['M3Hhl']['IU3TDG']; $item->accomodation_numberOfRooms = $M3['M3Hhl']['IU3NRM_']['roomCount']; $item->accomodation_roomType = $M3['M3Hhl']['IU3NRM_']['room']['room']['type']; $item->accomodation_roomType_translation = $M3['M3Hhl']['IU3NRM_']['room']['room']['translation']; $item->accomodation_roomClass = $M3['M3Hhl']['IU3NRM_']['room']['room']['class']; $item->accomodation_numberOfBeds = $M3['M3Hhl']['IU3NRM_']['room']['bedCount']; $item->accomodation_bedType = $M3['M3Hhl']['IU3NRM_']['room']['bed']['type']; $item->accomodation_ratePlan = $M3['M3Hhl']['IU3NRM_']['rate']['raw']; $item->accomodation_ratePlan_translation = $M3['M3Hhl']['IU3NRM_']['rate']['translation']; $item->accomodation_address[] = ['type'=>'default', 'value'=>implode(", ", $M3['M3Hhl']['hotelAddressAndPhone']['hotelAddressAndPhone_']['address']), ]; if ($M3['M3Hhl']['hotelAddressAndPhone']['hotelAddressAndPhone_']['phone']) { foreach ($M3['M3Hhl']['hotelAddressAndPhone']['hotelAddressAndPhone_']['phone'] as $phone) { $item->accomodation_contact_telephone[] = ['type'=>'default', 'value'=>$phone, ]; } } if ($M3['M3Hhl']['hotelAddressAndPhone']['hotelAddressAndPhone_']['fax']) { foreach ($M3['M3Hhl']['hotelAddressAndPhone']['hotelAddressAndPhone_']['fax'] as $fax) { $item->accomodation_contact_fax[] = ['type'=>'default', 'value'=>$fax, ]; } } return $item; } private function _getData_M3Oths_HHL() { list($parsedStructure, , $transactionIndexes) = $this->getTransactionDetails(); $M3 = $parsedStructure['M3'][$transactionIndexes['km3']]; $item = new \App\Sabre\StructureParser\Types\Supplier(); $item->name = ($M3['M3Oths']['IU3VR4_']['SUP']?:$M3['M3Oths']['IU3VR4_']['hotelName']); $item->accomodation_chainCode = $M3['M3Oths']['IU3VR4_']['chainCode']; $item->accomodation_roomType = $M3['M3Oths']['IU3VR4_']['roomType']; $item->accomodation_numberOfRooms = 1; $item->serviceName = $M3['M3Oths']['IU3VR4_']['hotelName']; return $item; } private function _getData_M3Oths_HHX() { list($parsedStructure, , $transactionIndexes) = $this->getTransactionDetails(); $M3 = $parsedStructure['M3'][$transactionIndexes['km3']]; $item = new \App\Sabre\StructureParser\Types\Supplier(); $item->name = $M3['M3Oths']['IU3VR4_']['HFN']; $item->accomodation_chainCode = $M3['M3Oths']['IU3VR4_']['PPC']; $item->accomodation_roomType = $M3['M3Oths']['IU3VR4_']['RTC']; $item->accomodation_numberOfRooms = 1; return $item; } } 