Code Duplication    Length = 34-46 lines in 4 locations

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/Stepup/Configuration/Value/RaLocationName.php 1 location

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

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

@@ 23-63 (lines=41) @@
20
21
use Surfnet\Stepup\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