Completed
Pull Request — master (#54)
by
unknown
01:34
created

HostedDomainException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
namespace League\OAuth2\Client\Exception;
4
5
/**
6
 * Exception thrown if the Google Provider is configured with a hosted domain that the user doesn't belong to
7
 */
8
class HostedDomainException extends \Exception
9
{
10
    private $hostedDomainConfigured;
11
12
    private $hostedDomainOfUser;
13
14
    /**
15
     * HostedDomainException constructor.
16
     * @param string $hostedDomainConfigured
17
     * @param string|null $hostedDomainOfUser
18
     */
19
    public function __construct($hostedDomainConfigured, $hostedDomainOfUser)
20
    {
21
        parent::__construct("Hosted domain mismatch '$hostedDomainOfUser' !== '$hostedDomainConfigured'");
22
        $this->hostedDomainConfigured = $hostedDomainConfigured;
23
        $this->hostedDomainOfUser = $hostedDomainOfUser;
24
    }
25
26
    /**
27
     * The hosted domain configured for this provider.
28
     * @return string
29
     */
30
    public function getHostedDomainConfigured()
31
    {
32
        return $this->hostedDomainConfigured;
33
    }
34
35
    /**
36
     * The hosted domain of the user. Non G-Suite users do not have hosted domains
37
     * @return string|null
38
     */
39
    public function getHostedDomainOfUser()
40
    {
41
        return $this->hostedDomainOfUser;
42
    }
43
}
44