Completed
Push — master ( 56a4b6...59de4e )
by Dieter
11:31
created

ProductInformation::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 11
cts 11
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 8
nop 3
crap 4
1
<?php
2
/**
3
 * amadeus-ws-client
4
 *
5
 * Copyright 2015 Amadeus Benelux NV
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 * http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 *
19
 * @package Amadeus
20
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
21
 */
22
23
namespace Amadeus\Client\Struct\Pnr\Retrieve;
24
25
use Amadeus\Client\Struct\Pnr\AddMultiElements\BoardOffPointDetail;
26
use Amadeus\Client\Struct\Pnr\AddMultiElements\Product;
27
use Amadeus\Client\Struct\Pnr\AddMultiElements\ProductDetails;
28
29
/**
30
 * ProductInformation
31
 *
32
 * @package Amadeus\Client\Struct\Pnr\Retrieve
33
 * @author Dieter Devlieghere <[email protected]>
34
 */
35
class ProductInformation
36
{
37
    /**
38
     * @var Product
39
     */
40
    public $product;
41
42
    /**
43
     * @var BoardOffPointDetail
44
     */
45
    public $boardpointDetail;
46
47
    /**
48
     * @var BoardOffPointDetail
49
     */
50
    public $offpointDetail;
51
52
    /**
53
     * @var Company
54
     */
55
    public $company;
56
57
    /**
58
     * @var ProductDetails
59
     */
60
    public $productDetails;
61
62
    /**
63
     * ProductInformation constructor.
64
     *
65
     * @param \DateTime|null $departureDate
66
     * @param string|null $company
67
     * @param string|null $flightNumber
68
     */
69 2
    public function __construct($departureDate, $company, $flightNumber)
70
    {
71 2
        if ($departureDate instanceof \DateTime) {
72 2
            $this->product = new Product($departureDate);
73 2
        }
74
75 2
        if ($company) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $company of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
76 1
            $this->company = new Company($company);
77 1
        }
78
79 2
        if ($flightNumber) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $flightNumber of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
80 1
            $this->productDetails = new ProductDetails($flightNumber);
81 1
        }
82 2
    }
83
}
84