Failed Conditions
Pull Request — master (#790)
by Guilherme
07:57
created

AuthorizationEvent::getPerson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\OpenIDBundle\Event;
12
13
use LoginCidadao\CoreBundle\Entity\Authorization;
14
use LoginCidadao\CoreBundle\Model\PersonInterface;
15
use LoginCidadao\OAuthBundle\Model\ClientInterface;
16
use LoginCidadao\RemoteClaimsBundle\Model\RemoteClaimInterface;
17
use Symfony\Component\EventDispatcher\Event;
18
19
class AuthorizationEvent extends Event
20
{
21
    /** @var Authorization */
22
    private $authorization;
23
24
    /** @var PersonInterface */
25
    private $person;
26
27
    /** @var ClientInterface */
28
    private $client;
29
30
    /** @var string[] */
31
    private $scope;
32
33
    /** @var RemoteClaimInterface[]|null */
34
    private $remoteClaims;
35
36
    /**
37
     * AuthorizationEvent constructor
38
     * @param PersonInterface $person
39
     * @param ClientInterface $client
40
     * @param string|string[] $scope scope authorized by the End-User
41
     */
42 6
    public function __construct(PersonInterface $person, ClientInterface $client, $scope)
43
    {
44 6
        $this->person = $person;
45 6
        $this->client = $client;
46 6
        $this->setScope($scope);
47 6
    }
48
49
    /**
50
     * @return string[]
51
     */
52 3
    public function getScope()
53
    {
54 3
        return $this->scope;
55
    }
56
57 6
    private function setScope($scope)
58
    {
59 6
        if (!is_array($scope)) {
60 4
            $scope = explode(' ', $scope);
61
        }
62 6
        $this->scope = $scope;
63
64 6
        return $this;
65
    }
66
67
    /**
68
     * @return Authorization|null
69
     */
70 6
    public function getAuthorization()
71
    {
72 6
        return $this->authorization;
73
    }
74
75
    /**
76
     * @param Authorization $authorization
77
     * @return AuthorizationEvent
78
     */
79 4
    public function setAuthorization($authorization)
80
    {
81 4
        $this->authorization = $authorization;
82
83 4
        return $this;
84
    }
85
86
    /**
87
     * @return PersonInterface
88
     */
89 2
    public function getPerson()
90
    {
91 2
        return $this->person;
92
    }
93
94
    /**
95
     * @return ClientInterface
96
     */
97 2
    public function getClient()
98
    {
99 2
        return $this->client;
100
    }
101
102 1
    public function getRemoteClaims()
103
    {
104 1
        return $this->remoteClaims;
105
    }
106
107 1
    public function setRemoteClaims(array $remoteClaims)
108
    {
109 1
        $this->remoteClaims = $remoteClaims;
110
111 1
        return $this;
112
    }
113
114 1
    public function addRemoteClaim(RemoteClaimInterface $remoteClaim)
115
    {
116 1
        $this->remoteClaims[] = $remoteClaim;
117
118 1
        return $this;
119
    }
120
}
121