Completed
Push — master ( 18f0a3...40f7e4 )
by Dieter
09:05
created

ItemNumber::__construct()   B

Complexity

Conditions 6
Paths 9

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 19
ccs 16
cts 16
cp 1
rs 8.8571
cc 6
eloc 11
nc 9
nop 2
crap 6
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\Fare\CheckRules;
24
25
/**
26
 * ItemNumber
27
 *
28
 * @package Amadeus\Client\Struct\Fare\CheckRules
29
 * @author Dieter Devlieghere <[email protected]>
30
 */
31
class ItemNumber
32
{
33
    /**
34
     * @var ItemNumberDetails[]
35
     */
36
    public $itemNumberDetails = [];
37
38
    /**
39
     * ItemNumber constructor.
40
     *
41
     * @param array|string|null $itemNum
42
     * @param int[] $fareComponents
0 ignored issues
show
Documentation introduced by
Should the type for parameter $fareComponents not be integer[]|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
43
     */
44 6
    public function __construct($itemNum = null, $fareComponents = null)
45
    {
46 6
        if (is_array($itemNum)) {
47 5
            foreach ($itemNum as $item) {
48 5
                $this->itemNumberDetails[] = new ItemNumberDetails($item);
49 5
            }
50 6
        } elseif (!is_null($itemNum)) {
51 1
            $this->itemNumberDetails[] = new ItemNumberDetails($itemNum);
52 1
        }
53
54 6
        if (is_array($fareComponents)) {
55 5
            foreach ($fareComponents as $fareComponent) {
56 1
                $this->itemNumberDetails[] = new ItemNumberDetails(
57 1
                    $fareComponent,
58
                    ItemNumberDetails::TYPE_FARE_COMPONENT
59 1
                );
60 5
            }
61 5
        }
62 6
    }
63
}
64