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

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