Code Duplication    Length = 58-58 lines in 3 locations

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

@@ 24-81 (lines=58) @@
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 isOption($option){
65
        return is_array($this->selectRaaOption) && in_array($this->selectRaaOption, $option);
66
    }
67
68
    public function hasOptions(){
69
        return is_array($this->selectRaaOption);
70
    }
71
72
    public function equals(SelectRaaOption $other)
73
    {
74
        return $this->getSelectRaaOption() === $other->getSelectRaaOption();
75
    }
76
77
    public function jsonSerialize()
78
    {
79
        return $this->getSelectRaaOption();
80
    }
81
}
82

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

@@ 24-81 (lines=58) @@
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 isOption($option){
65
        return is_array($this->useRaaOption) && in_array($this->useRaaOption, $option);
66
    }
67
68
    public function hasOptions(){
69
        return is_array($this->useRaaOption);
70
    }
71
72
    public function equals(UseRaaOption $other)
73
    {
74
        return $this->getUseRaaOption() === $other->getUseRaaOption();
75
    }
76
77
    public function jsonSerialize()
78
    {
79
        return $this->getUseRaaOption();
80
    }
81
}
82

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

@@ 24-81 (lines=58) @@
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
    public function isOption($option){
59
        return is_array($this->useRaOption) && in_array($this->useRaOption, $option);
60
    }
61
62
    public function hasOptions(){
63
        return is_array($this->useRaOption);
64
    }
65
    /**
66
     * If array, returns the array sorted
67
     * @return null|string[]
68
     */
69
    public function getUseRaOption()
70
    {
71
        if (is_array($this->useRaOption)) {
72
            sort($this->useRaOption);
73
        }
74
        return $this->useRaOption;
75
    }
76
77
    public function jsonSerialize()
78
    {
79
        return $this->getUseRaOption();
80
    }
81
}
82