Code Duplication    Length = 49-50 lines in 3 locations

src/Surfnet/Stepup/Configuration/Value/SelectRaaOption.php 1 location

@@ 24-72 (lines=49) @@
21
use JsonSerializable;
22
use Surfnet\Stepup\Exception\InvalidArgumentException;
23
24
class SelectRaaOption implements JsonSerializable
25
{
26
    /**
27
     * @var string[]|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
        $this->institutions = $selectRaaOption;
46
47
        // Sort the array values alphabetically
48
        if (is_array($this->institutions)) {
49
            sort($this->institutions);
50
        }
51
    }
52
53
    public static function getDefault()
54
    {
55
        return new self(null);
56
    }
57
58
    public function getInstitutions()
59
    {
60
        return $this->institutions;
61
    }
62
63
    public function equals(SelectRaaOption $other)
64
    {
65
        return $this->getInstitutions() === $other->getInstitutions();
66
    }
67
68
    public function jsonSerialize()
69
    {
70
        return $this->getInstitutions();
71
    }
72
}
73

src/Surfnet/Stepup/Configuration/Value/UseRaaOption.php 1 location

@@ 24-72 (lines=49) @@
21
use JsonSerializable;
22
use Surfnet\Stepup\Exception\InvalidArgumentException;
23
24
class UseRaaOption implements JsonSerializable
25
{
26
    /**
27
     * @var string[]|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
        $this->institutions = $useRaaOption;
46
        
47
        // Sort the array values alphabetically
48
        if (is_array($this->institutions)) {
49
            sort($this->institutions);
50
        }
51
    }
52
53
    public static function getDefault()
54
    {
55
        return new self(null);
56
    }
57
58
    public function getInstitutions()
59
    {
60
        return $this->institutions;
61
    }
62
63
    public function equals(UseRaaOption $other)
64
    {
65
        return $this->getInstitutions() === $other->getInstitutions();
66
    }
67
68
    public function jsonSerialize()
69
    {
70
        return $this->getInstitutions();
71
    }
72
}
73

src/Surfnet/Stepup/Configuration/Value/UseRaOption.php 1 location

@@ 24-73 (lines=50) @@
21
use JsonSerializable;
22
use Surfnet\Stepup\Exception\InvalidArgumentException;
23
24
class UseRaOption implements JsonSerializable
25
{
26
    /**
27
     * @var string[]|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
46
        $this->institutions = $useRaOption;
47
48
        // Sort the array values alphabetically
49
        if (is_array($this->institutions)) {
50
            sort($this->institutions);
51
        }
52
    }
53
54
    public static function getDefault()
55
    {
56
        return new self(null);
57
    }
58
59
    public function equals(UseRaOption $other)
60
    {
61
        return $this->getInstitutions() === $other->getInstitutions();
62
    }
63
64
    public function getInstitutions()
65
    {
66
        return $this->institutions;
67
    }
68
69
    public function jsonSerialize()
70
    {
71
        return $this->getInstitutions();
72
    }
73
}
74