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

HostedDomainException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getHostedDomainConfigured() 0 4 1
A getHostedDomainOfUser() 0 4 1
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