Passed
Push — master ( ba7d8d...e67af9 )
by Luiz Kim
02:11
created

Address::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ControleOnline\Entity;
4
5
use ApiPlatform\Metadata\GetCollection;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\GetCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use ApiPlatform\Metadata\Get;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Get was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use ApiPlatform\Metadata\ApiResource;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiResource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use ApiPlatform\Metadata\ApiProperty;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiProperty was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\SearchFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use ApiPlatform\Metadata\ApiFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Symfony\Component\Serializer\Annotation\Groups;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Serializer\Annotation\Groups was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
/**
15
 * Address
16
 *
17
 * @ORM\EntityListeners ({App\Listener\LogListener::class})
18
 * @ORM\Table (name="address", uniqueConstraints={@ORM\UniqueConstraint (name="user_id_3", columns={"people_id", "number", "street_id", "complement"})}, indexes={@ORM\Index (name="user_id_2", columns={"people_id","nickname"}), @ORM\Index(name="user_id", columns={"people_id"}), @ORM\Index(name="cep_id", columns={"street_id"})})
19
 * @ORM\Entity (repositoryClass="ControleOnline\Repository\AddressRepository")
20
 */
21
#[ApiResource(operations: [new Get(security: 'is_granted(\'ROLE_CLIENT\')'), new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')')], formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], normalizationContext: ['groups' => ['address_read']], denormalizationContext: ['groups' => ['address_write']])]
22
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])]
23
class Address
24
{
25
    /**
26
     * @var integer
27
     *
28
     * @ORM\Column(name="id", type="integer", nullable=false)
29
     * @ORM\Id
30
     * @ORM\GeneratedValue(strategy="IDENTITY")
31
     */
32
    private $id;
33
    /**
34
     * @var integer
35
     *
36
     * @ORM\Column(name="number", type="integer", nullable=true)
37
     * @Groups({"people_read", "address_read"})
38
     */
39
    private $number;
40
    /**
41
     * @var string
42
     *
43
     * @ORM\Column(name="nickname", type="string", length=50, nullable=false)
44
     * @Groups({"people_read", "address_read"})
45
     */
46
    private $nickname;
47
    /**
48
     * @var string
49
     *
50
     * @ORM\Column(name="complement", type="string", length=50, nullable=false)
51
     * @Groups({"people_read", "address_read"})
52
     */
53
    private $complement;
54
    /**
55
     * @var \ControleOnline\Entity\People
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\People was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
56
     *
57
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People", inversedBy="address")
58
     * @ORM\JoinColumns({
59
     *   @ORM\JoinColumn(name="people_id", referencedColumnName="id", nullable=true)
60
     * })
61
     */
62
    private $people;
63
    /**
64
     * @var \ControleOnline\Entity\Street
65
     *
66
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Street", inversedBy="address")
67
     * @ORM\JoinColumns({
68
     *   @ORM\JoinColumn(name="street_id", referencedColumnName="id", nullable=false)
69
     * })
70
     * @Groups({"people_read", "address_read"})
71
     */
72
    private $street;
73
    /**
74
     * @var float
75
     *
76
     * @ORM\Column(name="latitude", type="float", nullable=false)
77
     * @Groups({"people_read"})
78
     */
79
    private $latitude;
80
    /**
81
     * @var float
82
     *
83
     * @ORM\Column(name="longitude", type="float", nullable=false)
84
     * @Groups({"people_read"})
85
     */
86
    private $longitude;
87
    /**
88
     * @var string
89
     *
90
     * @ORM\Column(name="locator", type="string", nullable=false)
91
     * @Groups({"people_read"})
92
     */
93
    private $locator;
94
    /**
95
     * @var Datetime
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Datetime was not found. Did you mean Datetime? If so, make sure to prefix the type with \.
Loading history...
96
     *
97
     * @ORM\Column(name="opening_time", type="time", nullable=false)
98
     * @Groups({"people_read"})
99
     */
100
    private $opening_time;
101
    /**
102
     * @var Datetime
103
     *
104
     * @ORM\Column(name="closing_time", type="time", nullable=false)
105
     * @Groups({"people_read"})
106
     */
107
    private $closing_time;
108
    /**
109
     * @var string
110
     *
111
     * @ORM\Column(name="search_for", type="string", nullable=false)
112
     * @Groups({"people_read"})
113
     */
114
    private $search_for;
115
    /**
116
     * Constructor
117
     */
118
    public function __construct()
119
    {
120
        $this->latitude = 0;
121
        $this->longitude = 0;
122
    }
123
    /**
124
     * Get id
125
     *
126
     * @return integer
127
     */
128
    public function getId()
129
    {
130
        return $this->id;
131
    }
132
    /**
133
     * Set number
134
     *
135
     * @param integer $number
136
     * @return Address
137
     */
138
    public function setNumber($number)
139
    {
140
        $this->number = $number;
141
        return $this;
142
    }
143
    /**
144
     * Get number
145
     *
146
     * @return integer
147
     */
148
    public function getNumber()
149
    {
150
        return $this->number;
151
    }
152
    /**
153
     * Set nickname
154
     *
155
     * @param string $nickname
156
     * @return Address
157
     */
158
    public function setNickname($nickname)
159
    {
160
        $this->nickname = $nickname;
161
        return $this;
162
    }
163
    /**
164
     * Get nickname
165
     *
166
     * @return string
167
     */
168
    public function getNickname()
169
    {
170
        return strtoupper($this->nickname);
171
    }
172
    /**
173
     * Set complement
174
     *
175
     * @param string $complement
176
     * @return Address
177
     */
178
    public function setComplement($complement)
179
    {
180
        $this->complement = $complement;
181
        return $this;
182
    }
183
    /**
184
     * Get complement
185
     *
186
     * @return string
187
     */
188
    public function getComplement()
189
    {
190
        return strtoupper($this->complement);
191
    }
192
    /**
193
     * Set people
194
     *
195
     * @param \ControleOnline\Entity\People $people
196
     * @return Address
197
     */
198
    public function setPeople(\ControleOnline\Entity\People $people = null)
199
    {
200
        $this->people = $people;
201
        return $this;
202
    }
203
    /**
204
     * Get people
205
     *
206
     * @return \ControleOnline\Entity\People
207
     */
208
    public function getPeople() : People
209
    {
210
        return $this->people;
211
    }
212
    /**
213
     * Set street
214
     *
215
     * @param \ControleOnline\Entity\Street $street
216
     * @return Address
217
     */
218
    public function setStreet(\ControleOnline\Entity\Street $street = null)
219
    {
220
        $this->street = $street;
221
        return $this;
222
    }
223
    /**
224
     * Get street
225
     *
226
     * @return \ControleOnline\Entity\Street
227
     */
228
    public function getStreet()
229
    {
230
        return $this->street;
231
    }
232
    /**
233
     * Set latitude
234
     *
235
     * @param string $latitude
236
     * @return Address
237
     */
238
    public function setLatitude($latitude)
239
    {
240
        $this->latitude = $latitude ?: 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like $latitude ?: 0 can also be of type string. However, the property $latitude is declared as type double. 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...
241
        return $this;
242
    }
243
    /**
244
     * Get latitude
245
     *
246
     * @return string
247
     */
248
    public function getLatitude()
249
    {
250
        return $this->latitude;
251
    }
252
    /**
253
     * Set longitude
254
     *
255
     * @param string $longitude
256
     * @return Address
257
     */
258
    public function setLongitude($longitude)
259
    {
260
        $this->longitude = $longitude ?: 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like $longitude ?: 0 can also be of type string. However, the property $longitude is declared as type double. 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...
261
        return $this;
262
    }
263
    /**
264
     * Get longitude
265
     *
266
     * @return string
267
     */
268
    public function getLongitude()
269
    {
270
        return $this->longitude;
271
    }
272
273
    /**
274
     * Get the value of locator     
275
     * @return string
276
     */
277
    public function getLocator()
278
    {
279
        return $this->locator;
280
    }
281
282
    /**
283
     * Set the value of locator
284
     */
285
    public function setLocator($locator)
286
    {
287
        $this->locator = $locator;
288
289
        return $this;
290
    }
291
292
    /**
293
     * Get the value of opening_time
294
     */
295
    public function getOpeningTime()
296
    {
297
        return $this->opening_time;
298
    }
299
300
    /**
301
     * Set the value of opening_time
302
     */
303
    public function setOpeningTime($opening_time): self
304
    {
305
        $this->opening_time = $opening_time;
306
307
        return $this;
308
    }
309
310
    /**
311
     * Get the value of closing_time
312
     */
313
    public function getClosingTime()
314
    {
315
        return $this->closing_time;
316
    }
317
318
    /**
319
     * Set the value of closing_time
320
     */
321
    public function setClosingTime($closing_time): self
322
    {
323
        $this->closing_time = $closing_time;
324
325
        return $this;
326
    }
327
    
328
    /**
329
     * Get the value of search_for
330
     */
331
    public function getSearchFor()
332
    {
333
        return $this->search_for;
334
    }
335
336
    /**
337
     * Set the value of search_for
338
     */
339
    public function setSearchFor(string $search_for = null): self
340
    {
341
        $this->search_for = $search_for;
342
343
        return $this;
344
    }
345
}
346