Completed
Push — issue#666 ( 5bb037...827179 )
by Guilherme
04:30 queued 33s
created

RemoteClaim::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 6
ccs 2
cts 2
cp 1
crap 1
rs 9.4285
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
     * @return TagUri
83
     */
84
    public function getName()
85 12
    {
86
        return $this->name;
87 12
    }
88
89 12
    /**
90
     * @param TagUri $name
91
     * @return RemoteClaim
92
     */
93
    public function setName(TagUri $name)
94
    {
95 4
        $this->name = $name;
96
97 4
        return $this;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getDisplayName()
104 10
    {
105
        return $this->displayName;
106 10
    }
107
108 10
    /**
109
     * @param string $displayName
110
     * @return RemoteClaim
111
     */
112
    public function setDisplayName($displayName)
113
    {
114 4
        $this->displayName = $displayName;
115
116 4
        return $this;
117
    }
118
119
    /**
120
     * @return string
121
     */
122
    public function getDescription()
123 10
    {
124
        return $this->description;
125 10
    }
126
127 10
    /**
128
     * @param string $description
129
     * @return RemoteClaim
130
     */
131
    public function setDescription($description)
132
    {
133 8
        $this->description = $description;
134
135 8
        return $this;
136
    }
137
138
    /**
139
     * @return ClaimProviderInterface
140
     */
141
    public function getProvider()
142 12
    {
143
        return $this->provider;
144 12
    }
145
146 12
    /**
147
     * @param ClaimProviderInterface $provider
148
     * @return RemoteClaim
149
     */
150
    public function setProvider(ClaimProviderInterface $provider)
151
    {
152 4
        $this->provider = $provider;
153
154 4
        return $this;
155
    }
156
157
    /**
158
     * @return string[]
159
     */
160
    public function getRecommendedScope()
161 10
    {
162
        return $this->providerRecommendedScope;
163
    }
164 10
165
    /**
166 10
     * @param string|string[] $recommendedScope
167
     * @return RemoteClaimInterface
168
     */
169
    public function setRecommendedScope($recommendedScope)
170
    {
171
172 4
        $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...
173
174 4
        return $this;
175
    }
176
177
    /**
178
     * @return string[]
179
     */
180
    public function getEssentialScope()
181 10
    {
182
        return $this->providerEssentialScope;
183 10
    }
184
185 10
    /**
186
     * @param string|string[] $essentialScope
187
     * @return RemoteClaimInterface
188
     */
189
    public function setEssentialScope($essentialScope)
190
    {
191
        $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...
192
193
        return $this;
194
    }
195
}
196