@@ 24-69 (lines=46) @@ | ||
21 | use JsonSerializable; |
|
22 | use Surfnet\Stepup\Exception\InvalidArgumentException; |
|
23 | ||
24 | final class Institution implements JsonSerializable |
|
25 | { |
|
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $institution; |
|
30 | ||
31 | /** |
|
32 | * @param string $institution may not be an empty string |
|
33 | */ |
|
34 | public function __construct($institution) |
|
35 | { |
|
36 | if (!is_string($institution) || strlen(trim($institution)) === 0) { |
|
37 | throw InvalidArgumentException::invalidType('non-empty string', 'institution', $institution); |
|
38 | } |
|
39 | ||
40 | $this->institution = trim($institution); |
|
41 | } |
|
42 | ||
43 | /** |
|
44 | * @return string |
|
45 | */ |
|
46 | public function getInstitution() |
|
47 | { |
|
48 | return $this->institution; |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * @param Institution $otherInstitution |
|
53 | * @return bool |
|
54 | */ |
|
55 | public function equals(Institution $otherInstitution) |
|
56 | { |
|
57 | return $this->institution === $otherInstitution->institution; |
|
58 | } |
|
59 | ||
60 | public function jsonSerialize() |
|
61 | { |
|
62 | return $this->institution; |
|
63 | } |
|
64 | ||
65 | public function __toString() |
|
66 | { |
|
67 | return $this->institution; |
|
68 | } |
|
69 | } |
|
70 |
@@ 24-73 (lines=50) @@ | ||
21 | use JsonSerializable; |
|
22 | use Surfnet\Stepup\Exception\InvalidArgumentException; |
|
23 | ||
24 | final class CommonName implements JsonSerializable |
|
25 | { |
|
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $commonName; |
|
30 | ||
31 | /** |
|
32 | * @return self |
|
33 | */ |
|
34 | public static function unknown() |
|
35 | { |
|
36 | return new self('—'); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * @param string $commonName |
|
41 | */ |
|
42 | public function __construct($commonName) |
|
43 | { |
|
44 | if (!is_string($commonName) || trim($commonName) === '') { |
|
45 | throw InvalidArgumentException::invalidType('non-empty string', 'commonName', $commonName); |
|
46 | } |
|
47 | ||
48 | $this->commonName = trim($commonName); |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * @return string |
|
53 | */ |
|
54 | public function getCommonName() |
|
55 | { |
|
56 | return $this->commonName; |
|
57 | } |
|
58 | ||
59 | public function __toString() |
|
60 | { |
|
61 | return $this->commonName; |
|
62 | } |
|
63 | ||
64 | public function equals(CommonName $other) |
|
65 | { |
|
66 | return $this->commonName === $other->commonName; |
|
67 | } |
|
68 | ||
69 | public function jsonSerialize() |
|
70 | { |
|
71 | return $this->commonName; |
|
72 | } |
|
73 | } |
|
74 |
@@ 23-63 (lines=41) @@ | ||
20 | ||
21 | use Surfnet\Stepup\Exception\InvalidArgumentException; |
|
22 | ||
23 | final class GssfId implements SecondFactorIdentifier |
|
24 | { |
|
25 | /** |
|
26 | * @var string |
|
27 | */ |
|
28 | private $gssfId; |
|
29 | ||
30 | public static function unknown() |
|
31 | { |
|
32 | return new self('—'); |
|
33 | } |
|
34 | ||
35 | public function __construct($gssfId) |
|
36 | { |
|
37 | if (!is_string($gssfId) || trim($gssfId) === '') { |
|
38 | throw InvalidArgumentException::invalidType('non-empty string', 'gssfId', $gssfId); |
|
39 | } |
|
40 | ||
41 | $this->gssfId = trim($gssfId); |
|
42 | } |
|
43 | ||
44 | public function getValue() |
|
45 | { |
|
46 | return $this->gssfId; |
|
47 | } |
|
48 | ||
49 | public function __toString() |
|
50 | { |
|
51 | return $this->gssfId; |
|
52 | } |
|
53 | ||
54 | public function equals(SecondFactorIdentifier $other) |
|
55 | { |
|
56 | return $other instanceof self && $this->gssfId === $other->gssfId; |
|
57 | } |
|
58 | ||
59 | public function jsonSerialize() |
|
60 | { |
|
61 | return $this->gssfId; |
|
62 | } |
|
63 | } |
|
64 |
@@ 24-69 (lines=46) @@ | ||
21 | use JsonSerializable; |
|
22 | use Surfnet\Stepup\Exception\InvalidArgumentException; |
|
23 | ||
24 | final class Institution implements JsonSerializable |
|
25 | { |
|
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $institution; |
|
30 | ||
31 | /** |
|
32 | * @param string $institution may not be an empty string |
|
33 | */ |
|
34 | public function __construct($institution) |
|
35 | { |
|
36 | if (!is_string($institution) || strlen(trim($institution)) === 0) { |
|
37 | throw InvalidArgumentException::invalidType('non-empty string', 'institution', $institution); |
|
38 | } |
|
39 | ||
40 | $this->institution = trim($institution); |
|
41 | } |
|
42 | ||
43 | /** |
|
44 | * @return string |
|
45 | */ |
|
46 | public function getInstitution() |
|
47 | { |
|
48 | return $this->institution; |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * @param Institution $otherInstitution |
|
53 | * @return bool |
|
54 | */ |
|
55 | public function equals(Institution $otherInstitution) |
|
56 | { |
|
57 | return $this->institution === $otherInstitution->institution; |
|
58 | } |
|
59 | ||
60 | public function jsonSerialize() |
|
61 | { |
|
62 | return $this->institution; |
|
63 | } |
|
64 | ||
65 | public function __toString() |
|
66 | { |
|
67 | return $this->institution; |
|
68 | } |
|
69 | } |
|
70 |
@@ 23-56 (lines=34) @@ | ||
20 | ||
21 | use Surfnet\Stepup\Exception\InvalidArgumentException; |
|
22 | ||
23 | final class StepupProvider |
|
24 | { |
|
25 | /** |
|
26 | * @var string |
|
27 | */ |
|
28 | private $provider; |
|
29 | ||
30 | public function __construct($provider) |
|
31 | { |
|
32 | if (!is_string($provider) || strlen(trim($provider)) === 0) { |
|
33 | throw InvalidArgumentException::invalidType('non-empty string', 'provider', $provider); |
|
34 | } |
|
35 | ||
36 | $this->provider = trim($provider); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * @return string |
|
41 | */ |
|
42 | public function getStepupProvider() |
|
43 | { |
|
44 | return $this->provider; |
|
45 | } |
|
46 | ||
47 | public function equals(StepupProvider $other) |
|
48 | { |
|
49 | return $this->provider === $other->provider; |
|
50 | } |
|
51 | ||
52 | public function __toString() |
|
53 | { |
|
54 | return $this->provider; |
|
55 | } |
|
56 | } |
|
57 |