| @@ 24-79 (lines=56) @@ | ||
| 21 | use JsonSerializable; |
|
| 22 | use Surfnet\Stepup\Exception\InvalidArgumentException; |
|
| 23 | ||
| 24 | class SelectRaaOption implements JsonSerializable |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * @var InstitutionSet|null |
|
| 28 | */ |
|
| 29 | private $institutions; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * SelectRaaOption constructor. |
|
| 33 | * @param string[]|null $selectRaaOption |
|
| 34 | */ |
|
| 35 | public function __construct($selectRaaOption) |
|
| 36 | { |
|
| 37 | if (!is_null($selectRaaOption) && !is_array($selectRaaOption)) { |
|
| 38 | throw InvalidArgumentException::invalidType( |
|
| 39 | 'null or string[]', |
|
| 40 | 'selectRaaOption', |
|
| 41 | $selectRaaOption |
|
| 42 | ); |
|
| 43 | } |
|
| 44 | ||
| 45 | // Sort the array values alphabetically |
|
| 46 | if (is_array($selectRaaOption)) { |
|
| 47 | sort($selectRaaOption); |
|
| 48 | $this->institutions = InstitutionSet::fromInstitutionConfig($selectRaaOption); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| 52 | public static function getDefault() |
|
| 53 | { |
|
| 54 | return new self(null); |
|
| 55 | } |
|
| 56 | ||
| 57 | public function getInstitutions() |
|
| 58 | { |
|
| 59 | return $this->institutions; |
|
| 60 | } |
|
| 61 | ||
| 62 | public function equals(SelectRaaOption $other) |
|
| 63 | { |
|
| 64 | $thisValue = null; |
|
| 65 | $otherValue = null; |
|
| 66 | if (!is_null($this->getInstitutions())) { |
|
| 67 | $thisValue = $this->getInstitutions()->toScalarArray(); |
|
| 68 | } |
|
| 69 | if (!is_null($other->getInstitutions())) { |
|
| 70 | $otherValue = $other->getInstitutions()->toScalarArray(); |
|
| 71 | } |
|
| 72 | return $thisValue === $otherValue; |
|
| 73 | } |
|
| 74 | ||
| 75 | public function jsonSerialize() |
|
| 76 | { |
|
| 77 | return $this->getInstitutions()->toScalarArray(); |
|
| 78 | } |
|
| 79 | } |
|
| 80 | ||
| @@ 24-79 (lines=56) @@ | ||
| 21 | use JsonSerializable; |
|
| 22 | use Surfnet\Stepup\Exception\InvalidArgumentException; |
|
| 23 | ||
| 24 | class UseRaaOption implements JsonSerializable |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * @var InstitutionSet|null |
|
| 28 | */ |
|
| 29 | private $institutions; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * UseRaaOption constructor. |
|
| 33 | * @param string[]|null $useRaaOption |
|
| 34 | */ |
|
| 35 | public function __construct($useRaaOption) |
|
| 36 | { |
|
| 37 | if (!is_null($useRaaOption) && !is_array($useRaaOption)) { |
|
| 38 | throw InvalidArgumentException::invalidType( |
|
| 39 | 'null or string[]', |
|
| 40 | 'useRaaOption', |
|
| 41 | $useRaaOption |
|
| 42 | ); |
|
| 43 | } |
|
| 44 | ||
| 45 | // Sort the array values alphabetically |
|
| 46 | if (is_array($useRaaOption)) { |
|
| 47 | sort($useRaaOption); |
|
| 48 | $this->institutions = InstitutionSet::fromInstitutionConfig($useRaaOption); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| 52 | public static function getDefault() |
|
| 53 | { |
|
| 54 | return new self(null); |
|
| 55 | } |
|
| 56 | ||
| 57 | public function equals(UseRaaOption $other) |
|
| 58 | { |
|
| 59 | $thisValue = null; |
|
| 60 | $otherValue = null; |
|
| 61 | if (!is_null($this->getInstitutions())) { |
|
| 62 | $thisValue = $this->getInstitutions()->toScalarArray(); |
|
| 63 | } |
|
| 64 | if (!is_null($other->getInstitutions())) { |
|
| 65 | $otherValue = $other->getInstitutions()->toScalarArray(); |
|
| 66 | } |
|
| 67 | return $thisValue === $otherValue; |
|
| 68 | } |
|
| 69 | ||
| 70 | public function getInstitutions() |
|
| 71 | { |
|
| 72 | return $this->institutions; |
|
| 73 | } |
|
| 74 | ||
| 75 | public function jsonSerialize() |
|
| 76 | { |
|
| 77 | return $this->getInstitutions()->toScalarArray(); |
|
| 78 | } |
|
| 79 | } |
|
| 80 | ||
| @@ 24-79 (lines=56) @@ | ||
| 21 | use JsonSerializable; |
|
| 22 | use Surfnet\Stepup\Exception\InvalidArgumentException; |
|
| 23 | ||
| 24 | class UseRaOption implements JsonSerializable |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * @var InstitutionSet|null |
|
| 28 | */ |
|
| 29 | private $institutions; |
|
| 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 | // Sort the array values alphabetically |
|
| 46 | if (is_array($useRaOption)) { |
|
| 47 | sort($useRaOption); |
|
| 48 | $this->institutions = InstitutionSet::fromInstitutionConfig($useRaOption); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| 52 | public static function getDefault() |
|
| 53 | { |
|
| 54 | return new self(null); |
|
| 55 | } |
|
| 56 | ||
| 57 | public function equals(UseRaOption $other) |
|
| 58 | { |
|
| 59 | $thisValue = null; |
|
| 60 | $otherValue = null; |
|
| 61 | if (!is_null($this->getInstitutions())) { |
|
| 62 | $thisValue = $this->getInstitutions()->toScalarArray(); |
|
| 63 | } |
|
| 64 | if (!is_null($other->getInstitutions())) { |
|
| 65 | $otherValue = $other->getInstitutions()->toScalarArray(); |
|
| 66 | } |
|
| 67 | return $thisValue === $otherValue; |
|
| 68 | } |
|
| 69 | ||
| 70 | public function getInstitutions() |
|
| 71 | { |
|
| 72 | return $this->institutions; |
|
| 73 | } |
|
| 74 | ||
| 75 | public function jsonSerialize() |
|
| 76 | { |
|
| 77 | return $this->getInstitutions()->toScalarArray(); |
|
| 78 | } |
|
| 79 | } |
|
| 80 | ||