Passed
Pull Request — master (#269)
by
unknown
07:05
created

AuthParams::loadFromArray()   A

Complexity

Conditions 6
Paths 17

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 13
cts 13
cp 1
rs 9.2222
c 0
b 0
f 0
cc 6
nc 17
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\Params;
24
25
/**
26
 * AuthParams defines necessary authentication parameters for Amadeus Web Service client authentication.
27
 *
28
 * @package Amadeus\Client\Params
29
 * @author Dieter Devlieghere <[email protected]>
30
 */
31
class AuthParams
32
{
33
    /**
34
     * The Amadeus Office ID to sign in to
35
     *
36
     * @var string
37
     */
38
    public $officeId;
39
40
    /**
41
     * Originator Typecode
42
     *
43
     * @var string
44
     */
45
    public $originatorTypeCode = "U";
46
47
    /**
48
     * Duty code
49
     *
50
     * @var string
51
     */
52
    public $dutyCode = "SU";
53
54
    /**
55
     * User ID / Originator
56
     *
57
     * @var string
58
     */
59
    public $userId;
60
61
    /**
62
     * Password Length of plain password.
63
     *
64
     * Only for SoapHeader < 4.
65
     *
66
     * @var int
67
     */
68
    public $passwordLength;
69
70
    /**
71
     * Password Data (base-64 encoded password)
72
     *
73
     * @var string
74
     */
75
    public $passwordData;
76
77
    /**
78
     * Custom Nonce base to use when generating nonces for authentication
79
     *
80
     * Only applies to Soap Header V4
81
     *
82
     * If you do not provide one, the Session HandlerFactory will generate a random string.
83
     *
84
     * @var string
85
     */
86
    public $nonceBase;
87
88
    /**
89
     * @param array $params
90
     */
91 284
    public function __construct($params = [])
92
    {
93 284
        $this->loadFromArray($params);
94 284
    }
95
96
    /**
97
     * Load parameters from an associative array
98
     *
99
     * @param array $params
100
     * @return void
101
     */
102 284
    protected function loadFromArray(array $params)
103
    {
104 284
        if (count($params) > 0) {
105 284
            $this->officeId = $params['officeId'];
106 284
            $this->originatorTypeCode = (isset($params['originatorTypeCode'])) ? $params['originatorTypeCode'] : "U";
107 284
            $this->dutyCode = (isset($params['dutyCode'])) ? $params['dutyCode'] : "SU";
108 284
            $this->userId = $params['userId'];
109 284
            $this->passwordLength = (isset($params['passwordLength'])) ? $params['passwordLength'] : null;
110 284
            $this->passwordData = $params['passwordData'];
111
112 284
            if (isset($params['nonceBase'])) {
113 4
                $this->nonceBase = $params['nonceBase'];
114 2
            }
115 142
        }
116 284
    }
117
}
118