| @@ 34-124 (lines=91) @@ | ||
| 31 | * @package Amadeus\Client\Struct\Fare\InformativePricing13 |
|
| 32 | * @author Dieter Devlieghere <[email protected]> |
|
| 33 | */ |
|
| 34 | class SegmentGroup |
|
| 35 | { |
|
| 36 | /** |
|
| 37 | * @var SegmentInformation |
|
| 38 | */ |
|
| 39 | public $segmentInformation; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @var AdditionalSegmentDetails |
|
| 43 | */ |
|
| 44 | public $additionnalSegmentDetails; |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @var Inventory |
|
| 48 | */ |
|
| 49 | public $inventory; |
|
| 50 | ||
| 51 | /** |
|
| 52 | * SegmentGroup constructor. |
|
| 53 | * |
|
| 54 | * @param Segment $options |
|
| 55 | */ |
|
| 56 | public function __construct($options) |
|
| 57 | { |
|
| 58 | $this->segmentInformation = new SegmentInformation( |
|
| 59 | $options->segmentTattoo, |
|
| 60 | $options->departureDate, |
|
| 61 | $options->from, |
|
| 62 | $options->to, |
|
| 63 | $options->marketingCompany, |
|
| 64 | $options->flightNumber, |
|
| 65 | $options->bookingClass |
|
| 66 | ); |
|
| 67 | ||
| 68 | $this->loadOptionalSegmentInformation($options); |
|
| 69 | ||
| 70 | $this->loadInventory($options->inventory); |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * Load non-required options if available |
|
| 75 | * |
|
| 76 | * @param Segment $options |
|
| 77 | */ |
|
| 78 | protected function loadOptionalSegmentInformation($options) |
|
| 79 | { |
|
| 80 | if (!empty($options->operatingCompany)) { |
|
| 81 | $this->segmentInformation->companyDetails->operatingCompany = $options->operatingCompany; |
|
| 82 | } |
|
| 83 | ||
| 84 | if ($options->arrivalDate instanceof \DateTime) { |
|
| 85 | $this->segmentInformation->flightDate->setArrivalDate($options->arrivalDate); |
|
| 86 | } |
|
| 87 | ||
| 88 | if (!empty($options->groupNumber)) { |
|
| 89 | $this->segmentInformation->flightTypeDetails = new FlightTypeDetails($options->groupNumber); |
|
| 90 | } |
|
| 91 | ||
| 92 | $this->loadAdditionalSegmentDetails($options->airplaneCode, $options->nrOfStops); |
|
| 93 | } |
|
| 94 | ||
| 95 | /** |
|
| 96 | * @param string|null $airplaneCode |
|
| 97 | * @param int|null $nrOfStops |
|
| 98 | */ |
|
| 99 | protected function loadAdditionalSegmentDetails($airplaneCode, $nrOfStops) |
|
| 100 | { |
|
| 101 | if (!empty($airplaneCode) || !empty($nrOfStops)) { |
|
| 102 | $this->additionnalSegmentDetails = new AdditionalSegmentDetails($airplaneCode, $nrOfStops); |
|
| 103 | } |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Load inventory information |
|
| 108 | * |
|
| 109 | * @param array $inventory |
|
| 110 | */ |
|
| 111 | protected function loadInventory($inventory) |
|
| 112 | { |
|
| 113 | if (is_array($inventory) && count($inventory) > 0) { |
|
| 114 | $this->inventory = new Inventory(); |
|
| 115 | ||
| 116 | foreach ($inventory as $bookingClass => $availabilityAmount) { |
|
| 117 | $this->inventory->bookingClassDetails[] = new BookingClassDetails( |
|
| 118 | $bookingClass, |
|
| 119 | $availabilityAmount |
|
| 120 | ); |
|
| 121 | } |
|
| 122 | } |
|
| 123 | } |
|
| 124 | } |
|
| 125 | ||
| @@ 35-125 (lines=91) @@ | ||
| 32 | * @package Amadeus\Client\Struct\Service\StandaloneCatalogue |
|
| 33 | * @author Arvind Pandey <[email protected]> |
|
| 34 | */ |
|
| 35 | class FlightInfo |
|
| 36 | { |
|
| 37 | /** |
|
| 38 | * @var flightDetails |
|
| 39 | */ |
|
| 40 | public $flightDetails; |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @var AdditionalSegmentDetails |
|
| 44 | */ |
|
| 45 | public $additionnalSegmentDetails; |
|
| 46 | ||
| 47 | /** |
|
| 48 | * @var Inventory |
|
| 49 | */ |
|
| 50 | public $inventory; |
|
| 51 | ||
| 52 | /** |
|
| 53 | * SegmentGroup constructor. |
|
| 54 | * |
|
| 55 | * @param Segment $options |
|
| 56 | */ |
|
| 57 | public function __construct($options) |
|
| 58 | { |
|
| 59 | $this->flightDetails = new SegmentInformation( |
|
| 60 | $options->segmentTattoo, |
|
| 61 | $options->departureDate, |
|
| 62 | $options->from, |
|
| 63 | $options->to, |
|
| 64 | $options->marketingCompany, |
|
| 65 | $options->flightNumber, |
|
| 66 | $options->bookingClass |
|
| 67 | ); |
|
| 68 | ||
| 69 | $this->loadOptionalSegmentInformation($options); |
|
| 70 | ||
| 71 | $this->loadInventory($options->inventory); |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| 75 | * Load non-required options if available |
|
| 76 | * |
|
| 77 | * @param Segment $options |
|
| 78 | */ |
|
| 79 | protected function loadOptionalSegmentInformation($options) |
|
| 80 | { |
|
| 81 | if (!empty($options->operatingCompany)) { |
|
| 82 | $this->flightDetails->companyDetails->operatingCompany = $options->operatingCompany; |
|
| 83 | } |
|
| 84 | ||
| 85 | if ($options->arrivalDate instanceof \DateTime) { |
|
| 86 | $this->flightDetails->flightDate->setArrivalDate($options->arrivalDate); |
|
| 87 | } |
|
| 88 | ||
| 89 | if (!empty($options->groupNumber)) { |
|
| 90 | $this->flightDetails->flightTypeDetails = new FlightTypeDetails($options->groupNumber); |
|
| 91 | } |
|
| 92 | ||
| 93 | $this->loadAdditionalSegmentDetails($options->airplaneCode, $options->nrOfStops); |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @param string|null $airplaneCode |
|
| 98 | * @param int|null $nrOfStops |
|
| 99 | */ |
|
| 100 | protected function loadAdditionalSegmentDetails($airplaneCode, $nrOfStops) |
|
| 101 | { |
|
| 102 | if (!empty($airplaneCode) || !empty($nrOfStops)) { |
|
| 103 | $this->additionalFlightInfo = new AdditionalSegmentDetails($airplaneCode, $nrOfStops); |
|
| 104 | } |
|
| 105 | } |
|
| 106 | ||
| 107 | /** |
|
| 108 | * Load inventory information |
|
| 109 | * |
|
| 110 | * @param array $inventory |
|
| 111 | */ |
|
| 112 | protected function loadInventory($inventory) |
|
| 113 | { |
|
| 114 | if (is_array($inventory) && count($inventory) > 0) { |
|
| 115 | $this->inventory = new Inventory(); |
|
| 116 | ||
| 117 | foreach ($inventory as $bookingClass => $availabilityAmount) { |
|
| 118 | $this->inventory->bookingClassDetails[] = new BookingClassDetails( |
|
| 119 | $bookingClass, |
|
| 120 | $availabilityAmount |
|
| 121 | ); |
|
| 122 | } |
|
| 123 | } |
|
| 124 | } |
|
| 125 | } |
|
| 126 | ||