Completed
Push — issue#666 ( 928a8e...2654e9 )
by Guilherme
04:24
created

RemoteClaim::setRecommendedScope()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
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\RemoteClaimsBundle\Entity;
12
13
use Doctrine\ORM\Mapping as ORM;
14
use LoginCidadao\RemoteClaimsBundle\Model\ClaimProviderInterface;
15
use LoginCidadao\RemoteClaimsBundle\Model\RemoteClaimInterface;
16
use LoginCidadao\RemoteClaimsBundle\Model\TagUri;
17
use LoginCidadao\RemoteClaimsBundle\Validator\Constraints\HostBelongsToClaimProvider;
18
19
/**
20
 * RemoteClaim
21
 * @package LoginCidadao\RemoteClaimsBundle\Entity
22
 * @HostBelongsToClaimProvider
23
 * @ORM\Entity(repositoryClass="LoginCidadao\RemoteClaimsBundle\Entity\RemoteClaimRepository")
24
 * @ORM\Table(name="remote_claim")
25
 */
26
class RemoteClaim implements RemoteClaimInterface
27
{
28
    /**
29
     * @ORM\Id
30
     * @ORM\Column(type="integer")
31
     * @ORM\GeneratedValue(strategy="AUTO")
32
     */
33
    protected $id;
34
35
    /**
36
     * @var TagUri
37
     * @ORM\Column(name="name", type="string", length=255, nullable=false)
38
     */
39
    private $name;
40
41
    /**
42
     * @var string
43
     * @ORM\Column(name="display_name", type="string", length=255, nullable=false)
44
     */
45
    private $displayName;
46
47
    /**
48
     * @var string
49
     * @ORM\Column(name="description", type="text", nullable=true)
50
     */
51
    private $description;
52
53
    /**
54
     * @var string[]
55
     * @ORM\Column(name="provider_recommended_scope", type="json_array", nullable=true)
56
     */
57
    private $providerRecommendedScope;
58
59
    /**
60
     * @var string[]
61
     * @ORM\Column(name="provider_essential_scope", type="json_array", nullable=true)
62
     */
63
    private $providerEssentialScope;
64
65
    /**
66
     * @var ClaimProviderInterface
67
     *
68
     * @ORM\OneToOne(targetEntity="LoginCidadao\OAuthBundle\Entity\Client")
69
     * @ORM\JoinColumn(name="provider_id", referencedColumnName="id")
70
     */
71
    private $provider;
72
73
    /**
74
     * @return mixed
75
     */
76 12
    public function getId()
77
    {
78 12
        return $this->id;
79
    }
80
81
    /**
82
     * @param mixed $id
83
     * @return RemoteClaim
84
     */
85 12
    public function setId($id)
86
    {
87 12
        $this->id = $id;
88
89 12
        return $this;
90
    }
91
92
    /**
93
     * @return TagUri
94
     */
95 4
    public function getName()
96
    {
97 4
        return $this->name;
98
    }
99
100
    /**
101
     * @param TagUri $name
102
     * @return RemoteClaim
103
     */
104 10
    public function setName(TagUri $name)
105
    {
106 10
        $this->name = $name;
107
108 10
        return $this;
109
    }
110
111
    /**
112
     * @return string
113
     */
114 4
    public function getDisplayName()
115
    {
116 4
        return $this->displayName;
117
    }
118
119
    /**
120
     * @param string $displayName
121
     * @return RemoteClaim
122
     */
123 10
    public function setDisplayName($displayName)
124
    {
125 10
        $this->displayName = $displayName;
126
127 10
        return $this;
128
    }
129
130
    /**
131
     * @return string
132
     */
133 8
    public function getDescription()
134
    {
135 8
        return $this->description;
136
    }
137
138
    /**
139
     * @param string $description
140
     * @return RemoteClaim
141
     */
142 12
    public function setDescription($description)
143
    {
144 12
        $this->description = $description;
145
146 12
        return $this;
147
    }
148
149
    /**
150
     * @return ClaimProviderInterface
151
     */
152 4
    public function getProvider()
153
    {
154 4
        return $this->provider;
155
    }
156
157
    /**
158
     * @param ClaimProviderInterface $provider
159
     * @return RemoteClaim
160
     */
161 10
    public function setProvider(ClaimProviderInterface $provider)
162
    {
163
        $this->provider = $provider;
164 10
165
        return $this;
166 10
    }
167
168
    /**
169
     * @return string[]
170
     */
171
    public function getRecommendedScope()
172 4
    {
173
        return $this->providerRecommendedScope;
174 4
    }
175
176
    /**
177
     * @param string|string[] $recommendedScope
178
     * @return RemoteClaimInterface
179
     */
180
    public function setRecommendedScope($recommendedScope)
181 10
    {
182
183 10
        $this->providerRecommendedScope = $recommendedScope;
0 ignored issues
show
Documentation Bug introduced by
It seems like $recommendedScope can also be of type string. However, the property $providerRecommendedScope is declared as type array<integer,string>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
184
185 10
        return $this;
186
    }
187
188
    /**
189
     * @return string[]
190
     */
191
    public function getEssentialScope()
192
    {
193
        return $this->providerEssentialScope;
194
    }
195
196
    /**
197
     * @param string|string[] $essentialScope
198
     * @return RemoteClaimInterface
199
     */
200
    public function setEssentialScope($essentialScope)
201
    {
202
        $this->providerEssentialScope = $essentialScope;
0 ignored issues
show
Documentation Bug introduced by
It seems like $essentialScope can also be of type string. However, the property $providerEssentialScope is declared as type array<integer,string>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
203
204
        return $this;
205
    }
206
}
207