Completed
Push — master ( fbae33...af8390 )
by Dieter
06:48
created

QueueList::__construct()   B

Complexity

Conditions 6
Paths 16

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 20
cts 20
cp 1
rs 8.8657
c 0
b 0
f 0
cc 6
nc 16
nop 1
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\Queue;
24
25
use Amadeus\Client\RequestOptions\QueueListOptions;
26
use Amadeus\Client\Struct\BaseWsMessage;
27
28
/**
29
 * Structure class for representing the Queue_List request message
30
 *
31
 * @package Amadeus\Client\Struct\Queue
32
 * @author Dieter Devlieghere <[email protected]>
33
 */
34
class QueueList extends BaseWsMessage
35
{
36
    /**
37
     * @var Scroll
38
     */
39
    public $scroll;
40
41
    /**
42
     * @var TargetOffice
43
     */
44
    public $targetOffice;
45
46
    /**
47
     * @var QueueNumber
48
     */
49
    public $queueNumber;
50
51
    /**
52
     * @var CategoryDetails
53
     */
54
    public $categoryDetails;
55
56
    /**
57
     * @var QueueDate
58
     */
59
    public $date;
60
61
    /**
62
     * @var ScanRange
63
     */
64
    public $scanRange;
65
66
    /**
67
     * @var SearchCriteria[]
68
     */
69
    public $searchCriteria = [];
70
71
    /**
72
     * @var SortCriteria
73
     */
74
    public $sortCriteria;
75
76
    /**
77
     * @param QueueListOptions $options
78
     */
79 32
    public function __construct(QueueListOptions $options)
80
    {
81 32
        $this->queueNumber = new QueueNumber($options->queue->queue);
82
83 32
        $this->categoryDetails = new CategoryDetails($options->queue->category);
84
85 32
        if (!empty($options->queue->timeMode)) {
86 4
            $this->date = new QueueDate($options->queue->timeMode);
87 2
        }
88
        
89 32
        if (!empty($options->queue->officeId)) {
90 8
            $this->targetOffice = new TargetOffice(
91 8
                SourceType::SOURCETYPE_OFFICE_SPECIFIED,
92 8
                $options->queue->officeId
93 4
            );
94 4
        }
95
96 32
        $this->sortCriteria = new SortCriteria($options->sortType);
97
98 32
        foreach ($options->searchCriteria as $opt) {
99 4
            $this->searchCriteria[] = new SearchCriteria($opt);
100 16
        }
101
102 32
        if (is_int($options->firstItemNr) && is_int($options->lastItemNr)) {
103 4
            $this->scanRange = new ScanRange($options->firstItemNr, $options->lastItemNr);
104 2
        }
105 32
    }
106
}
107