Passed
Pull Request — master (#484)
by Artem
03:36
created

SeatAvailability   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 17
c 1
b 0
f 0
dl 0
loc 35
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 23 6
1
<?php
2
3
namespace Amadeus\Client\Struct\Travel;
4
5
use Amadeus\Client\RequestOptions\TravelSeatAvailabilityOptions;
6
use Amadeus\Client\Struct\BaseWsMessage;
7
use Amadeus\Client\Struct\Travel\SeatAvailability\Offer;
8
9
/**
10
 * Travel_SeatAvailability message structure
11
 *
12
 * @package Amadeus\Client\Struct\Travel
13
 * @author Artem Zakharchenko <[email protected]>
14
 */
15
class SeatAvailability extends BaseWsMessage
16
{
17
    /**
18
     * @var Party
19
     */
20
    public $Party;
21
22
    /**
23
     * @var SeatAvailability\Request
24
     */
25
    public $Request;
26
27
    public function __construct(TravelSeatAvailabilityOptions $options)
28
    {
29
        $this->Party = new Party($options->party);
30
31
        $coreRequest = new SeatAvailability\CoreRequest();
32
33
        if (($orderId = $options->orderId) && ($ownerCode = $options->ownerCode)) {
34
            $coreRequest->setOrder(
35
                new Order(
36
                    $orderId,
37
                    $ownerCode
38
                )
39
            );
40
        } elseif (($offerItemId = $options->offerItemId) && ($ownerCode = $options->ownerCode)) {
41
            $coreRequest->setOffer(new Offer($offerItemId, $ownerCode));
42
        } else {
43
            throw new \InvalidArgumentException('Invalid combination of arguments at TravelSeatAvailabilityOptions');
44
        }
45
46
        $this->Request = new SeatAvailability\Request($coreRequest);
47
48
        if ($shoppingResponseId = $options->shoppingResponseId) {
49
            $this->Request->setShoppingResponse(new ShoppingResponse($shoppingResponseId));
50
        }
51
    }
52
}
53