1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2014 SURFnet bv |
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\Identity\Value; |
20
|
|
|
|
21
|
|
|
use JsonSerializable; |
22
|
|
|
use Surfnet\Stepup\Exception\InvalidArgumentException; |
23
|
|
|
|
24
|
|
|
final class DocumentNumber implements JsonSerializable |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $documentNumber; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return self |
33
|
|
|
*/ |
34
|
|
|
public static function unknown() |
35
|
|
|
{ |
36
|
|
|
return new self('—'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param string $documentNumber |
41
|
|
|
*/ |
42
|
|
|
public function __construct($documentNumber) |
43
|
|
|
{ |
44
|
|
|
if (!is_string($documentNumber) || empty($documentNumber)) { |
45
|
|
|
throw InvalidArgumentException::invalidType('non-empty string', 'documentNumber', $documentNumber); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$this->documentNumber = $documentNumber; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return string |
53
|
|
|
*/ |
54
|
|
|
public function getDocumentNumber() |
55
|
|
|
{ |
56
|
|
|
return $this->documentNumber; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function __toString() |
60
|
|
|
{ |
61
|
|
|
return $this->documentNumber; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function equals(DocumentNumber $other) |
65
|
|
|
{ |
66
|
|
|
return $this->documentNumber === $other->documentNumber; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function jsonSerialize() |
70
|
|
|
{ |
71
|
|
|
return $this->documentNumber; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|