Code Duplication    Length = 72-73 lines in 2 locations

src/Amadeus/Client/Struct/Fare/InformativePricingWithoutPNR13.php 1 location

@@ 41-112 (lines=72) @@
38
 * @package Amadeus\Client\Struct\Fare
39
 * @author Dieter Devlieghere <[email protected]>
40
 */
41
class InformativePricingWithoutPNR13 extends BaseWsMessage
42
{
43
    /**
44
     * @var OriginatorGroup
45
     */
46
    public $originatorGroup;
47
48
    /**
49
     * @var PassengersGroup[]
50
     */
51
    public $passengersGroup = [];
52
53
    /**
54
     * @var SegmentGroup[]
55
     */
56
    public $segmentGroup = [];
57
58
    /**
59
     * @var PricingOptionGroup[]
60
     */
61
    public $pricingOptionGroup = [];
62
63
    /**
64
     * InformativePricingWithoutPNR13 constructor.
65
     *
66
     * @param FareInformativePricingWithoutPnrOptions|null $options
67
     */
68
    public function __construct($options)
69
    {
70
        if (!is_null($options)) {
71
            $this->loadPassengers($options->passengers);
72
73
            $this->loadSegments($options->segments);
74
75
            $this->loadPricingOptions($options->pricingOptions);
76
        }
77
    }
78
79
    /**
80
     * @param Passenger[] $passengers
81
     */
82
    protected function loadPassengers($passengers)
83
    {
84
        $counter = 1;
85
86
        foreach ($passengers as $passenger) {
87
            $this->passengersGroup[] = new PassengersGroup($passenger, $counter);
88
            $counter++;
89
        }
90
    }
91
92
    /**
93
     * @param Segment[] $segments
94
     */
95
    protected function loadSegments($segments)
96
    {
97
        foreach ($segments as $segment) {
98
            $this->segmentGroup[] = new SegmentGroup($segment);
99
        }
100
    }
101
102
    /**
103
     * @param PricingOptions|null $pricingOptions
104
     */
105
    protected function loadPricingOptions($pricingOptions)
106
    {
107
        if (!($pricingOptions instanceof PricingOptions)) {
108
            $pricingOptions = new PricingOptions();
109
        }
110
        $this->pricingOptionGroup = PricePNRWithBookingClass13::loadPricingOptionsFromRequestOptions($pricingOptions);
111
    }
112
}
113

src/Amadeus/Client/Struct/Service/StandaloneCatalogue.php 1 location

@@ 39-111 (lines=73) @@
36
 * @package Amadeus\Client\Struct\Fare
37
 * @author StandaloneCatalogue.php
38
 */
39
class StandaloneCatalogue extends BaseWsMessage
40
{
41
42
    /**
43
     *
44
     * @var passengerInfoGroup[]
45
     */
46
    public $passengerInfoGroup = [];
47
48
    /**
49
     *
50
     * @var flightInfo[]
51
     */
52
    public $flightInfo = [];
53
54
    /**
55
     *
56
     * @var pricingOption[]
57
     */
58
    public $pricingOption = [];
59
60
    /**
61
     * StandaloneCatalogue constructor.
62
     *
63
     * @param ServiceStandaloneCatalogueOptions|null $options
64
     */
65
    public function __construct($options)
66
    {
67
        if (! is_null($options)) {
68
            $this->loadPassengers($options->passengers);
69
            
70
            $this->loadflightDetails($options->segments);
71
            
72
            $this->loadPricingOptions($options->pricingOptions);
73
        }
74
    }
75
76
    /**
77
     *
78
     * @param Passenger[] $passengers
79
     */
80
    protected function loadPassengers($passengers)
81
    {
82
        $counter = 1;
83
        foreach ($passengers as $passenger) {
84
            $this->passengerInfoGroup[] = new PassengerInfoGroup($passenger, $counter);
85
            $counter ++;
86
        }
87
    }
88
89
    /**
90
     *
91
     * @param Segment[] $segments
92
     */
93
    protected function loadflightDetails($segments)
94
    {
95
        foreach ($segments as $segment) {
96
            $this->flightInfo[] = new flightInfo($segment);
97
        }
98
    }
99
100
    /**
101
     *
102
     * @param PricingOptions|null $pricingOptions
103
     */
104
    protected function loadPricingOptions($pricingOptions)
105
    {
106
        if (! ($pricingOptions instanceof ServiceIntegratedPricingOptions)) {
107
            $pricingOptions = new ServiceIntegratedPricingOptions();
108
        }
109
        $this->pricingOption = IntegratedPricing::loadPricingOptions($pricingOptions);
110
    }
111
}
112