1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2018 SURFnet B.V. |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\Stepup\Configuration\Value; |
20
|
|
|
|
21
|
|
|
use JsonSerializable; |
22
|
|
|
use Surfnet\Stepup\Exception\InvalidArgumentException; |
23
|
|
|
|
24
|
|
|
class UseRaOption implements JsonSerializable |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var string[]|null |
28
|
|
|
*/ |
29
|
|
|
private $useRaOption; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* UseRaOption constructor. |
33
|
|
|
* @param null|array $useRaOption |
34
|
|
|
*/ |
35
|
|
|
public function __construct($useRaOption) |
36
|
|
|
{ |
37
|
|
|
if (!is_null($useRaOption) && !is_array($useRaOption)) { |
38
|
|
|
throw InvalidArgumentException::invalidType( |
39
|
|
|
'null or string[]', |
40
|
|
|
'useRaOption', |
41
|
|
|
$useRaOption |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
} |
45
|
|
|
$this->useRaOption = $useRaOption; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public static function getDefault() |
49
|
|
|
{ |
50
|
|
|
return new self(null); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function equals(UseRaOption $other) |
54
|
|
|
{ |
55
|
|
|
return $this->getUseRaOption() === $other->getUseRaOption(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* If array, returns the array sorted |
60
|
|
|
* @return null|string[] |
|
|
|
|
61
|
|
|
*/ |
62
|
|
|
public function getUseRaOption() |
63
|
|
|
{ |
64
|
|
|
if (is_array($this->useRaOption)) { |
65
|
|
|
sort($this->useRaOption); |
66
|
|
|
} |
67
|
|
|
return $this->useRaOption; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function jsonSerialize() |
71
|
|
|
{ |
72
|
|
|
return $this->getUseRaOption(); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.