Passed
Push — master ( 9b18a9...97fefd )
by Luiz Kim
12:36 queued 10:27
created

People::addCompany()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ControleOnline\Entity;
4
5
use ApiPlatform\Metadata\Post;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Post 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\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...
7
use ApiPlatform\Metadata\Delete;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Delete 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\Put;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Put 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\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...
10
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...
11
use App\Controller\GetCloseProfessionalsAction;
0 ignored issues
show
Bug introduced by
The type App\Controller\GetCloseProfessionalsAction 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 ControleOnline\Controller\GetDefaultCompanyAction;
13
use ControleOnline\Controller\GetMyCompaniesAction;
14
use Doctrine\Common\Collections\Collection;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\Collection 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...
15
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...
16
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...
17
use ControleOnline\Controller\CreateUserAction;
18
use stdClass;
19
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\DateFilter 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...
20
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...
21
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...
22
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\OrderFilter 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...
23
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...
24
use Symfony\Component\Validator\Constraints as Assert;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Validator\Constraints 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...
25
use ControleOnline\Controller\IncomeStatementAction;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Controller\IncomeStatementAction 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...
26
27
/**
28
 * @ORM\EntityListeners ({App\Listener\LogListener::class})
29
 * @ORM\Entity (repositoryClass="ControleOnline\Repository\PeopleRepository")
30
 * @ORM\Table (name="people")
31
 */
32
#[ApiResource(
33
    operations: [
34
35
        new Get(security: 'is_granted(\'ROLE_CLIENT\')'),
36
        new Post(
37
            uriTemplate: '/people/{id}/add-user',
38
            controller: CreateUserAction::class,
39
            securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')',
40
        ),
41
        new GetCollection(
42
            securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')',
43
        ),
44
        new GetCollection(
45
            security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')',
46
            uriTemplate: '/people/company/default',
47
            controller: GetDefaultCompanyAction::class
48
        ),
49
        new GetCollection(
50
            uriTemplate: '/people/companies/my',
51
            controller: GetMyCompaniesAction::class
52
        ),
53
54
        new GetCollection(
55
            uriTemplate: '/people/professionals/close/{lat}/{lng}',
56
            openapiContext: [],
57
            controller: GetCloseProfessionalsAction::class
58
        )
59
    ],
60
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
61
    security: 'is_granted(\'ROLE_CLIENT\')',
62
    normalizationContext: ['groups' => ['people_read']],
63
    denormalizationContext: ['groups' => ['people_write']]
64
)]
65
class People
66
{
67
    /**
68
     * @ORM\Column(type="integer", nullable=false)
69
     * @ORM\Id
70
     * @ORM\GeneratedValue(strategy="IDENTITY")
71
     * @Groups({
72
     *     "category_read","order_read", "document_read", "email_read", "people_read", "invoice_read",
73
     *      "order_detail_status_read", "mycontract_read",
74
     *     "my_contract_item_read", "mycontractpeople_read", 
75
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
76
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
77
     * })
78
     */
79
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
80
81
    private $id;
82
    /**
83
     * @ORM\Column(type="boolean",  nullable=false)
84
     * @Groups({
85
     *     "category_read","order_read", "document_read", "email_read", "people_read", "invoice_read",
86
     *      "order_detail_status_read", "mycontract_read",
87
     *     "my_contract_item_read", "mycontractpeople_read", 
88
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
89
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
90
     * })
91
     */
92
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['enable' => 'exact'])]
93
94
    private $enable = 0;
95
    /**
96
     * @ORM\Column(type="boolean",  nullable=false)
97
     * @Groups({
98
     *     "category_read","order_read", "document_read", "email_read", "people_read", "invoice_read",
99
     *      "order_detail_status_read", "mycontract_read",
100
     *     "my_contract_item_read", "mycontractpeople_read", 
101
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
102
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
103
     * })
104
     */
105
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['icms' => 'exact'])]
106
107
    private $icms = 1;
108
    /**
109
     * @ORM\Column(type="string", length=50, nullable=false)
110
     * @Groups({
111
     *     "category_read","order_read", "document_read", "email_read", "people_read",
112
     *     "invoice_read",  "order_detail_status_read", "mycontract_read",
113
     *     "my_contract_item_read", "mycontractpeople_read", 
114
     *      "task_read", "task_interaction_read","coupon_read", "logistic_read",
115
     *     "queue_read","display_read","notifications_read","people_provider_read"
116
     * })
117
     */
118
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'partial'])]
119
120
    private $name;
121
    /**
122
     * @ORM\Column(type="datetime", nullable=false, columnDefinition="DATETIME")
123
     */
124
    private $registerDate;
125
    /**
126
     * @ORM\Column(type="string", length=50, nullable=false)
127
     * @Groups({
128
     *     "category_read","order_read", "document_read", "email_read", "people_read", "invoice_read",
129
     *      "order_detail_status_read", "mycontract_read",
130
     *     "my_contract_item_read", "mycontractpeople_read", 
131
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
132
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
133
     * })
134
     */
135
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['alias' => 'partial'])]
136
137
    private $alias;
138
    /**
139
     * @var string
140
     *
141
     * @ORM\Column(name="other_informations", type="json",  nullable=true)
142
     * @Groups({
143
     *     "order_read", "document_read", "email_read", "people_read", "invoice_read",
144
     *      "order_detail_status_read", "mycontract_read",
145
     *      "my_contract_item_read", "mycontractpeople_read", 
146
     *      "task_read", "task_interaction_read","coupon_read"
147
     * }) 
148
     */
149
    private $otherInformations;
150
    /**
151
     * @ORM\Column(type="string", length=1, nullable=false)
152
     * @Groups({"pruduct_read","display_read","people_read", "my_contract_item_read", "mycontractpeople_read", "task_read", "task_interaction_read"})
153
     */
154
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['peopleType' => 'exact'])]
155
156
    private $peopleType = 'F';
157
    /**
158
     * @ORM\Column(type="float", nullable=false)
159
     * @Groups({"people_read"})
160
     */
161
    private $billing = 0;
162
    /**
163
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File", inversedBy="people")
164
     * @ORM\JoinColumns({
165
     *   @ORM\JoinColumn(name="image_id", referencedColumnName="id")
166
     * })
167
     * @Groups({"people_read","display_read"})
168
     */
169
    private $file;
170
    /**
171
     * @var Collection
172
     *
173
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\Config", mappedBy="people")
174
     * @ORM\OrderBy({"config_key" = "ASC"})
175
     */
176
    private $config;
177
    /**
178
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File")
179
     * @ORM\JoinColumns({
180
     *   @ORM\JoinColumn(name="alternative_image", referencedColumnName="id")
181
     * })
182
     */
183
    private $alternativeFile;
184
    /**
185
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File")
186
     * @ORM\JoinColumns({
187
     *   @ORM\JoinColumn(name="background_image", referencedColumnName="id")
188
     * })
189
     */
190
    private $backgroundFile;
191
    /**
192
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Language", inversedBy="people")
193
     * @ORM\JoinColumns({
194
     *   @ORM\JoinColumn(name="language_id", referencedColumnName="id")
195
     * })
196
     */
197
    private $language;
198
    /**
199
     * @var Collection
200
     *
201
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\PeopleLink", mappedBy="company")
202
     */
203
    private $company;
204
205
    /**
206
     * @var Collection
207
     *
208
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\PeopleLink", mappedBy="people")
209
     * 
210
     */
211
    private $link;
212
213
    /**
214
     * @var Collection
215
     *
216
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\User", mappedBy="people")
217
     * @ORM\OrderBy({"username" = "ASC"})
218
     * @Groups({"people_read"})
219
     */
220
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['user' => 'exact'])]
221
222
    private $user;
223
    /**
224
     * @var Collection
225
     *
226
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\Document", mappedBy="people")
227
     * @Groups({"people_read", "task_interaction_read"})
228
     */
229
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['document' => 'exact'])]
230
231
    private $document;
232
    /**
233
     * @var Collection
234
     *
235
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\Address", mappedBy="people")
236
     * @ORM\OrderBy({"nickname" = "ASC"})
237
     * @Groups({"people_read", "logistic_read"})
238
     */
239
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['address' => 'exact'])]
240
241
    private $address;
242
    /**
243
     * @var Collection
244
     *
245
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\Phone", mappedBy="people")
246
     * @Groups({"people_read",   "task_interaction_read"})
247
     */
248
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['phone' => 'exact'])]
249
250
    private $phone;
251
    /**
252
     * @var Collection
253
     *
254
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\Email", mappedBy="people")
255
     * @Groups({"people_read", "get_contracts",  "task_interaction_read"})
256
     */
257
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['email' => 'exact'])]
258
259
    private $email;
260
    /**
261
     * Many Peoples have Many Contracts.
262
     *
263
     * @ORM\OneToMany (targetEntity="ControleOnline\Entity\ContractPeople", mappedBy="people")
264
     */
265
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['contractsPeople' => 'exact'])]
266
267
    private $contractsPeople;
268
269
    /**
270
     * @ORM\Column(type="string", length=255, nullable=false)
271
     * @Groups({"people_read"})
272
     */
273
    private $billingDays;
274
    /**
275
     * @ORM\Column(type="integer", nullable=false)
276
     * @Groups({"people_read", "my_contract_item_read", "mycontractpeople_read"})
277
     */
278
    private $paymentTerm;
279
280
281
    /**
282
     * @ORM\Column(type="datetime", nullable=false, columnDefinition="DATETIME")
283
     * @Groups({"people_read", "my_contract_item_read", "mycontractpeople_read"})
284
     */
285
    private $foundationDate = null;
286
    /**
287
     * @Groups({"people_read", "my_contract_item_read", "mycontractpeople_read"})
288
     */
289
    private $averageRating = 4;
290
    public function __construct()
291
    {
292
        $this->enable = 0;
0 ignored issues
show
Documentation Bug introduced by
The property $enable was declared of type boolean, but 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
293
        $this->icms = 1;
0 ignored issues
show
Documentation Bug introduced by
The property $icms was declared of type boolean, but 1 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
294
        $this->billing = 0;
295
        $this->registerDate =            new \DateTime('now');
296
        $this->people =            new \Doctrine\Common\Collections\ArrayCollection();
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\ArrayCollection 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...
Bug Best Practice introduced by
The property people does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
297
        $this->config =            new \Doctrine\Common\Collections\ArrayCollection();
298
        $this->link =            new \Doctrine\Common\Collections\ArrayCollection();
299
        $this->user =            new \Doctrine\Common\Collections\ArrayCollection();
300
        $this->document =            new \Doctrine\Common\Collections\ArrayCollection();
301
        $this->address =            new \Doctrine\Common\Collections\ArrayCollection();
302
        $this->email =            new \Doctrine\Common\Collections\ArrayCollection();
303
        $this->phone =            new \Doctrine\Common\Collections\ArrayCollection();
304
        $this->billingDays = 'daily';
305
        $this->paymentTerm = 1;
306
307
        $this->otherInformations = json_encode(
308
            new stdClass()
309
        );
310
    }
311
    public function getId()
312
    {
313
        return $this->id;
314
    }
315
    public function getAverageRating()
316
    {
317
        return $this->averageRating;
318
    }
319
    public function setAverageRating($averageRating)
320
    {
321
        $this->averageRating = $averageRating;
322
        return $this;
323
    }
324
    public function getIcms()
325
    {
326
        return $this->icms;
327
    }
328
    public function setIcms($icms)
329
    {
330
        $this->icms = $icms ?: 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like $icms ?: 0 can also be of type integer. However, the property $icms is declared as type boolean. 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...
331
        return $this;
332
    }
333
    public function getEnabled()
334
    {
335
        return $this->enable;
336
    }
337
    public function setEnabled($enable)
338
    {
339
        $this->enable = $enable ?: 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like $enable ?: 0 can also be of type integer. However, the property $enable is declared as type boolean. 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...
340
        return $this;
341
    }
342
    public function setPeopleType($people_type)
343
    {
344
        $this->peopleType = $people_type;
345
        return $this;
346
    }
347
    public function getPeopleType()
348
    {
349
        return $this->peopleType;
350
    }
351
    /**
352
     * Set name.
353
     */
354
    public function setName(string $name): self
355
    {
356
        $this->name = $name;
357
        return $this;
358
    }
359
    /**
360
     * Get name.
361
     */
362
    public function getName(): string
363
    {
364
        return strtoupper($this->name);
365
    }
366
    public function setAlias($alias)
367
    {
368
        $this->alias = $alias;
369
        return $this;
370
    }
371
    public function getAlias()
372
    {
373
        return strtoupper($this->alias);
374
    }
375
    public function setFile(File $file = null)
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\File 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...
376
    {
377
        $this->file = $file;
378
        return $this;
379
    }
380
    public function getFile()
381
    {
382
        return $this->file;
383
    }
384
    public function setAlternativeFile(File $alternative_file = null)
385
    {
386
        $this->alternativeFile = $alternative_file;
387
        return $this;
388
    }
389
    public function getAlternativeFile()
390
    {
391
        return $this->alternativeFile;
392
    }
393
    public function getBackgroundFile()
394
    {
395
        return $this->backgroundFile;
396
    }
397
    public function setBackgroundFile(File $backgroundFile = null)
398
    {
399
        $this->backgroundFile = $backgroundFile;
400
        return $this;
401
    }
402
    public function setLanguage(Language $language = null)
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Language 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...
403
    {
404
        $this->language = $language;
405
        return $this;
406
    }
407
    public function getLanguage()
408
    {
409
        return $this->language;
410
    }
411
    public function setBilling($billing)
412
    {
413
        $this->billing = $billing;
414
        return $this;
415
    }
416
    public function getBilling()
417
    {
418
        return $this->billing;
419
    }
420
    public function getRegisterDate(): \DateTimeInterface
421
    {
422
        return $this->registerDate;
423
    }
424
    public function setRegisterDate(\DateTimeInterface $registerDate): self
425
    {
426
        $this->registerDate = $registerDate;
427
        return $this;
428
    }
429
    /**
430
     * Add document.
431
     *
432
     * @return Document
433
     */
434
    public function addDocument(Document $document)
435
    {
436
        $this->document[] = $document;
437
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type ControleOnline\Entity\People which is incompatible with the documented return type ControleOnline\Entity\Document.
Loading history...
438
    }
439
    /**
440
     * Add company.
441
     *
442
     * @return Company
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Company 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...
443
     */
444
    public function addCompany(People $company)
445
    {
446
        $this->company[] = $company;
447
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type ControleOnline\Entity\People which is incompatible with the documented return type ControleOnline\Entity\Company.
Loading history...
448
    }
449
    /**
450
     * Remove company.
451
     */
452
    public function removeCompany(People $company)
453
    {
454
        $this->company->removeElement($company);
455
    }
456
    /**
457
     * Get company.
458
     *
459
     * @return Collection
460
     */
461
    public function getCompany()
462
    {
463
        return $this->company;
464
    }
465
    /**
466
     * Add link.
467
     *
468
     * @return People
469
     */
470
    public function addLink(People $link)
471
    {
472
        $this->link[] = $link;
473
        return $this;
474
    }
475
    /**
476
     * Remove link.
477
     *
478
     * @param \Core\Entity\Link $link
0 ignored issues
show
Bug introduced by
The type Core\Entity\Link 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...
479
     */
480
    public function removeLink(People $link)
481
    {
482
        $this->link->removeElement($link);
483
    }
484
    /**
485
     * Get link.
486
     *
487
     * @return Collection
488
     */
489
    public function getLink()
490
    {
491
        return $this->link;
492
    }
493
    /**
494
     * Add user.
495
     *
496
     * @return People
497
     */
498
    public function addUser(\ControleOnline\Entity\User $user)
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\User 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...
499
    {
500
        $this->user[] = $user;
501
        return $this;
502
    }
503
    /**
504
     * Remove user.
505
     */
506
    public function removeUser(\ControleOnline\Entity\User $user)
507
    {
508
        $this->user->removeElement($user);
509
    }
510
    /**
511
     * Get user.
512
     *
513
     * @return Collection
514
     */
515
    public function getUser()
516
    {
517
        return $this->user;
518
    }
519
    /**
520
     * Get document.
521
     *
522
     * @return Collection
523
     */
524
    public function getDocument()
525
    {
526
        return $this->document;
527
    }
528
    /**
529
     * Get address.
530
     *
531
     * @return Collection
532
     */
533
    public function getAddress()
534
    {
535
        return $this->address;
536
    }
537
    /**
538
     * Get document.
539
     *
540
     * @return Collection
541
     */
542
    public function getPhone()
543
    {
544
        return $this->phone;
545
    }
546
    /**
547
     * Get email.
548
     *
549
     * @return Collection
550
     */
551
    public function getEmail()
552
    {
553
        return $this->email;
554
    }
555
    public function getContractsPeople(): Collection
556
    {
557
        return $this->contractsPeople;
558
    }
559
    public function setBillingDays(string $billingDays): self
560
    {
561
        $this->billingDays = $billingDays;
562
        return $this;
563
    }
564
    public function getBillingDays(): string
565
    {
566
        return $this->billingDays;
567
    }
568
    public function setPaymentTerm(int $paymentTerm): self
569
    {
570
        $this->paymentTerm = $paymentTerm;
571
        return $this;
572
    }
573
    public function getPaymentTerm(): int
574
    {
575
        return $this->paymentTerm;
576
    }
577
    public function getFoundationDate(): ?\DateTime
578
    {
579
        return $this->foundationDate;
580
    }
581
    public function setFoundationDate(\DateTimeInterface $date): self
582
    {
583
        $this->foundationDate = $date;
584
        return $this;
585
    }
586
    public function getFullName(): string
587
    {
588
        if ($this->getPeopleType() == 'F') {
589
            return trim(preg_replace('/[^A-Za-z\s]/', '', sprintf('%s %s', $this->getName(), $this->getAlias())));
590
        }
591
        return trim(preg_replace('/[^A-Za-z\s]/', '', $this->getName()));
592
    }
593
    public function isPerson(): bool
594
    {
595
        return $this->getPeopleType() == 'F';
596
    }
597
    public function getOneEmail(): ?Email
598
    {
599
        if (($email = $this->getEmail()->first()) === false) {
600
            return null;
601
        }
602
        return $email;
603
    }
604
    public function getOneDocument(): ?Document
605
    {
606
        $documents = $this->getDocument()->filter(function ($peopleDocument) {
607
            if ($peopleDocument->getPeople()->getPeopleType() == 'F') {
608
                return $peopleDocument->getDocumentType()->getDocumentType() == 'CPF';
609
            }
610
            return $peopleDocument->getDocumentType()->getDocumentType() == 'CNPJ';
611
        });
612
        return ($document = $documents->first()) === false ? null : $document;
613
    }
614
    public function getBirthdayAsString(): ?string
615
    {
616
        if ($this->getFoundationDate() instanceof \DateTimeInterface) {
617
            return $this->getFoundationDate()->format('Y-m-d');
618
        }
619
        return null;
620
    }
621
    /**
622
     * Get otherInformations
623
     *
624
     * @return stdClass
625
     */
626
    public function getOtherInformations($decode = false)
627
    {
628
        return $decode ? (object) json_decode(is_array($this->otherInformations) ? json_encode($this->otherInformations) : $this->otherInformations) : $this->otherInformations;
0 ignored issues
show
introduced by
The condition is_array($this->otherInformations) is always false.
Loading history...
Bug Best Practice introduced by
The expression return $decode ? (object...this->otherInformations also could return the type string which is incompatible with the documented return type stdClass.
Loading history...
629
    }
630
    /**
631
     * Set comments
632
     *
633
     * @param string $otherInformations
634
     * @return Order
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Order 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...
635
     */
636
    public function addOtherInformations($key, $value)
637
    {
638
        $otherInformations = $this->getOtherInformations(true);
639
        $otherInformations->{$key} = $value;
640
        $this->otherInformations = json_encode($otherInformations);
641
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type ControleOnline\Entity\People which is incompatible with the documented return type ControleOnline\Entity\Order.
Loading history...
642
    }
643
    /**
644
     * Set comments
645
     *
646
     * @param string $otherInformations
647
     * @return Order
648
     */
649
    public function setOtherInformations(stdClass $otherInformations)
650
    {
651
        $this->otherInformations = json_encode($otherInformations);
652
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type ControleOnline\Entity\People which is incompatible with the documented return type ControleOnline\Entity\Order.
Loading history...
653
    }
654
    /**
655
     * Add Config.
656
     *
657
     * @return People
658
     */
659
    public function addConfig(\ControleOnline\Entity\Config $config)
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Config 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...
660
    {
661
        $this->config[] = $config;
662
        return $this;
663
    }
664
    /**
665
     * Remove Config.
666
     */
667
    public function removeConfig(\ControleOnline\Entity\Config $config)
668
    {
669
        $this->config->removeElement($config);
670
    }
671
    /**
672
     * Get config.
673
     *
674
     * @return Collection
675
     */
676
    public function getConfig()
677
    {
678
        return $this->config;
679
    }
680
}
681