Code Duplication    Length = 50-51 lines in 3 locations

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

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

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

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

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

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