| @@ 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 | ||