Code Duplication    Length = 34-50 lines in 7 locations

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

@@ 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 __toString()
61
    {
62
        return $this->institution;
63
    }
64
65
    public function jsonSerialize()
66
    {
67
        return $this->institution;
68
    }
69
}
70

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

@@ 24-69 (lines=46) @@
21
use JsonSerializable;
22
use Surfnet\Stepup\Exception\InvalidArgumentException;
23
24
final class RaLocationName implements JsonSerializable
25
{
26
    /**
27
     * @var string
28
     */
29
    private $raLocationName;
30
31
    /**
32
     * @param string $raLocationName
33
     */
34
    public function __construct($raLocationName)
35
    {
36
        if (!is_string($raLocationName) || trim($raLocationName) === '') {
37
            throw InvalidArgumentException::invalidType('non-empty string', 'raLocationName', $raLocationName);
38
        }
39
40
        $this->raLocationName = $raLocationName;
41
    }
42
43
    /**
44
     * @param RaLocationName $otherRaLocationName
45
     * @return bool
46
     */
47
    public function equals(RaLocationName $otherRaLocationName)
48
    {
49
        return $this->raLocationName === $otherRaLocationName->raLocationName;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getRaLocationName()
56
    {
57
        return $this->raLocationName;
58
    }
59
60
    public function __toString()
61
    {
62
        return $this->raLocationName;
63
    }
64
65
    public function jsonSerialize()
66
    {
67
        return $this->raLocationName;
68
    }
69
}
70

src/Surfnet/Stepup/Identity/Value/CommonName.php 1 location

@@ 24-73 (lines=50) @@
21
use JsonSerializable;
22
use Surfnet\Stepup\Exception\InvalidArgumentException;
23
24
final class CommonName implements JsonSerializable
25
{
26
    /**
27
     * @var string
28
     */
29
    private $commonName;
30
31
    /**
32
     * @return self
33
     */
34
    public static function unknown()
35
    {
36
        return new self('—');
37
    }
38
39
    /**
40
     * @param string $commonName
41
     */
42
    public function __construct($commonName)
43
    {
44
        if (!is_string($commonName) || trim($commonName) === '') {
45
            throw InvalidArgumentException::invalidType('non-empty string', 'commonName', $commonName);
46
        }
47
48
        $this->commonName = trim($commonName);
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getCommonName()
55
    {
56
        return $this->commonName;
57
    }
58
59
    public function __toString()
60
    {
61
        return $this->commonName;
62
    }
63
64
    public function equals(CommonName $other)
65
    {
66
        return $this->commonName === $other->commonName;
67
    }
68
69
    public function jsonSerialize()
70
    {
71
        return $this->commonName;
72
    }
73
}
74

src/Surfnet/Stepup/Identity/Value/GssfId.php 1 location

@@ 23-63 (lines=41) @@
20
21
use Surfnet\Stepup\Exception\InvalidArgumentException;
22
23
final class GssfId implements SecondFactorIdentifier
24
{
25
    /**
26
     * @var string
27
     */
28
    private $gssfId;
29
30
    public static function unknown()
31
    {
32
        return new self('—');
33
    }
34
35
    public function __construct($gssfId)
36
    {
37
        if (!is_string($gssfId) || trim($gssfId) === '') {
38
            throw InvalidArgumentException::invalidType('non-empty string', 'gssfId', $gssfId);
39
        }
40
41
        $this->gssfId = trim($gssfId);
42
    }
43
44
    public function getValue()
45
    {
46
        return $this->gssfId;
47
    }
48
49
    public function __toString()
50
    {
51
        return $this->gssfId;
52
    }
53
54
    public function equals(SecondFactorIdentifier $other)
55
    {
56
        return $other instanceof self && $this->gssfId === $other->gssfId;
57
    }
58
59
    public function jsonSerialize()
60
    {
61
        return $this->gssfId;
62
    }
63
}
64

src/Surfnet/Stepup/Identity/Value/Institution.php 1 location

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

src/Surfnet/Stepup/Identity/Value/StepupProvider.php 1 location

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

src/Surfnet/StepupMiddleware/CommandHandlingBundle/Value/Institution.php 1 location

@@ 23-63 (lines=41) @@
20
21
use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\InvalidArgumentException;
22
23
final class Institution
24
{
25
    /**
26
     * @var string
27
     */
28
    private $institution;
29
30
    /**
31
     * @param string $institution may not be an empty string
32
     */
33
    public function __construct($institution)
34
    {
35
        if (!is_string($institution) || strlen(trim($institution)) === 0) {
36
            throw InvalidArgumentException::invalidType('non-empty string', 'institution', $institution);
37
        }
38
39
        $this->institution = trim($institution);
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getInstitution()
46
    {
47
        return $this->institution;
48
    }
49
50
    /**
51
     * @param Institution $otherInstitution
52
     * @return bool
53
     */
54
    public function equals(Institution $otherInstitution)
55
    {
56
        return $this->institution === $otherInstitution->institution;
57
    }
58
59
    public function __toString()
60
    {
61
        return $this->institution;
62
    }
63
}
64