Passed
Push — master ( 97fefd...2a9c36 )
by Luiz Kim
24:01 queued 21:57
created

People::getAlternativeFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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 ({ControleOnline\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 Put(
37
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
38
            validationContext: ['groups' => ['people_write']],
39
            denormalizationContext: ['groups' => ['people_write']]
40
        ),
41
        new Delete(security: 'is_granted(\'ROLE_CLIENT\')'),
42
        new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'),
43
        new Post(
44
            uriTemplate: '/people/{id}/add-user',
45
            controller: CreateUserAction::class,
46
            securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')',
47
        ),
48
        new GetCollection(
49
            securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')',
50
        ),
51
        new GetCollection(
52
            security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')',
53
            uriTemplate: '/people/company/default',
54
            controller: GetDefaultCompanyAction::class
55
        ),
56
        new GetCollection(
57
            uriTemplate: '/people/companies/my',
58
            controller: GetMyCompaniesAction::class
59
        ),
60
61
        new GetCollection(
62
            uriTemplate: '/people/professionals/close/{lat}/{lng}',
63
            openapiContext: [],
64
            controller: GetCloseProfessionalsAction::class
65
        )
66
    ],
67
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
68
    security: 'is_granted(\'ROLE_CLIENT\')',
69
    normalizationContext: ['groups' => ['people_read']],
70
    denormalizationContext: ['groups' => ['people_write']]
71
)]
72
class People
73
{
74
    /**
75
     * @ORM\Column(type="integer", nullable=false)
76
     * @ORM\Id
77
     * @ORM\GeneratedValue(strategy="IDENTITY")
78
     * @Groups({
79
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
80
     *      "order_detail_status_read", "mycontract_read",
81
     *     "my_contract_item_read", "mycontractpeople_read", 
82
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
83
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
84
     * })
85
     */
86
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
87
88
    private $id;
89
    /**
90
     * @ORM\Column(type="boolean",  nullable=false)
91
     * @Groups({
92
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
93
     *      "order_detail_status_read", "mycontract_read",
94
     *     "my_contract_item_read", "mycontractpeople_read", 
95
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
96
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
97
     * })
98
     */
99
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['enable' => 'exact'])]
100
101
    private $enable = 0;
102
103
    /**
104
     * @ORM\Column(type="string", length=50, nullable=false)
105
     * @Groups({
106
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
107
     *      "order_detail_status_read", "mycontract_read",
108
     *     "my_contract_item_read", "mycontractpeople_read", 
109
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
110
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
111
     * })
112
     */
113
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'partial'])]
114
115
    private $name;
116
    /**
117
     * @ORM\Column(type="datetime", nullable=false, columnDefinition="DATETIME")
118
     */
119
    private $registerDate;
120
    /**
121
     * @ORM\Column(type="string", length=50, nullable=false)
122
     * @Groups({
123
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
124
     *      "order_detail_status_read", "mycontract_read",
125
     *     "my_contract_item_read", "mycontractpeople_read", 
126
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
127
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
128
     * })
129
     */
130
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['alias' => 'partial'])]
131
132
    private $alias;
133
    /**
134
     * @var string
135
     *
136
     * @ORM\Column(name="other_informations", type="json",  nullable=true)
137
     * @Groups({
138
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
139
     *      "order_detail_status_read", "mycontract_read",
140
     *     "my_contract_item_read", "mycontractpeople_read", 
141
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
142
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
143
     * })
144
     */
145
    private $otherInformations;
146
    /**
147
     * @ORM\Column(type="string", length=1, nullable=false)
148
     * @Groups({
149
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
150
     *      "order_detail_status_read", "mycontract_read",
151
     *     "my_contract_item_read", "mycontractpeople_read", 
152
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
153
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
154
     * })
155
     */
156
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['peopleType' => 'exact'])]
157
158
    private $peopleType = 'F';
159
160
    /**
161
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File", inversedBy="people")
162
     * @ORM\JoinColumns({
163
     *   @ORM\JoinColumn(name="image_id", referencedColumnName="id")
164
     * })
165
     * @Groups({
166
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
167
     *      "order_detail_status_read", "mycontract_read",
168
     *     "my_contract_item_read", "mycontractpeople_read", 
169
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
170
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
171
     * })
172
     */
173
    private $file;
174
    /**
175
     * @var Collection
176
     *
177
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\Config", mappedBy="people")
178
     * @ORM\OrderBy({"config_key" = "ASC"})
179
     */
180
    private $config;
181
    /**
182
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File")
183
     * @ORM\JoinColumns({
184
     *   @ORM\JoinColumn(name="alternative_image", referencedColumnName="id")
185
     * })
186
     */
187
    private $alternativeFile;
188
    /**
189
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File")
190
     * @ORM\JoinColumns({
191
     *   @ORM\JoinColumn(name="background_image", referencedColumnName="id")
192
     * })
193
     */
194
    private $backgroundFile;
195
    /**
196
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Language", inversedBy="people")
197
     * @ORM\JoinColumns({
198
     *   @ORM\JoinColumn(name="language_id", referencedColumnName="id")
199
     * })
200
     */
201
    private $language;
202
    /**
203
     * @var Collection
204
     *
205
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\PeopleLink", mappedBy="company")
206
     */
207
    private $company;
208
209
    /**
210
     * @var Collection
211
     *
212
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\PeopleLink", mappedBy="people")
213
     * 
214
     */
215
    private $link;
216
217
    /**
218
     * @var Collection
219
     *
220
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\User", mappedBy="people")
221
     * @ORM\OrderBy({"username" = "ASC"})
222
     * @Groups({
223
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
224
     *      "order_detail_status_read", "mycontract_read",
225
     *     "my_contract_item_read", "mycontractpeople_read", 
226
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
227
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
228
     * })
229
     */
230
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['user' => 'exact'])]
231
232
    private $user;
233
    /**
234
     * @var Collection
235
     *
236
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\Document", mappedBy="people")
237
     * @Groups({
238
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
239
     *      "order_detail_status_read", "mycontract_read",
240
     *     "my_contract_item_read", "mycontractpeople_read", 
241
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
242
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
243
     * })
244
     */
245
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['document' => 'exact'])]
246
247
    private $document;
248
    /**
249
     * @var Collection
250
     *
251
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\Address", mappedBy="people")
252
     * @ORM\OrderBy({"nickname" = "ASC"})
253
     * @Groups({
254
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
255
     *      "order_detail_status_read", "mycontract_read",
256
     *     "my_contract_item_read", "mycontractpeople_read", 
257
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
258
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
259
     * })
260
     */
261
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['address' => 'exact'])]
262
263
    private $address;
264
    /**
265
     * @var Collection
266
     *
267
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\Phone", mappedBy="people")
268
     * @Groups({
269
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
270
     *      "order_detail_status_read", "mycontract_read",
271
     *     "my_contract_item_read", "mycontractpeople_read", 
272
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
273
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
274
     * })
275
     */
276
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['phone' => 'exact'])]
277
278
    private $phone;
279
    /**
280
     * @var Collection
281
     *
282
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\Email", mappedBy="people")
283
     * @Groups({
284
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
285
     *      "order_detail_status_read", "mycontract_read",
286
     *     "my_contract_item_read", "mycontractpeople_read", 
287
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
288
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
289
     * })
290
     */
291
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['email' => 'exact'])]
292
293
    private $email;
294
    /**
295
     * Many Peoples have Many Contracts.
296
     *
297
     * @ORM\OneToMany (targetEntity="ControleOnline\Entity\ContractPeople", mappedBy="people")
298
     */
299
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['contractsPeople' => 'exact'])]
300
301
    private $contractsPeople;
302
303
    /**
304
     * @ORM\Column(type="datetime", nullable=false, columnDefinition="DATETIME")
305
     * @Groups({
306
     *     "category_read","order_read", "document_read", "email_read", "people_read","people_write", "invoice_read",
307
     *      "order_detail_status_read", "mycontract_read",
308
     *     "my_contract_item_read", "mycontractpeople_read", 
309
     *      "task_read", "task_interaction_read","coupon_read","logistic_read",
310
     *     "pruduct_read","queue_read","display_read","notifications_read","people_provider_read"
311
     * })
312
     */
313
    private $foundationDate = null;
314
315
316
    public function __construct()
317
    {
318
        $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...
319
        $this->registerDate =            new \DateTime('now');
320
        $this->company =            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...
321
        $this->config =            new \Doctrine\Common\Collections\ArrayCollection();
322
        $this->link =            new \Doctrine\Common\Collections\ArrayCollection();
323
        $this->user =            new \Doctrine\Common\Collections\ArrayCollection();
324
        $this->document =            new \Doctrine\Common\Collections\ArrayCollection();
325
        $this->address =            new \Doctrine\Common\Collections\ArrayCollection();
326
        $this->email =            new \Doctrine\Common\Collections\ArrayCollection();
327
        $this->phone =            new \Doctrine\Common\Collections\ArrayCollection();
328
        $this->otherInformations = json_encode(
329
            new stdClass()
330
        );
331
    }
332
    public function getId()
333
    {
334
        return $this->id;
335
    }
336
337
338
    public function getEnabled()
339
    {
340
        return $this->enable;
341
    }
342
    public function setEnabled($enable)
343
    {
344
        $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...
345
        return $this;
346
    }
347
    public function setPeopleType($people_type)
348
    {
349
        $this->peopleType = $people_type;
350
        return $this;
351
    }
352
    public function getPeopleType()
353
    {
354
        return $this->peopleType;
355
    }
356
    /**
357
     * Set name.
358
     */
359
    public function setName(string $name): self
360
    {
361
        $this->name = $name;
362
        return $this;
363
    }
364
    /**
365
     * Get name.
366
     */
367
    public function getName(): string
368
    {
369
        return strtoupper($this->name);
370
    }
371
    public function setAlias($alias)
372
    {
373
        $this->alias = $alias;
374
        return $this;
375
    }
376
    public function getAlias()
377
    {
378
        return strtoupper($this->alias);
379
    }
380
    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...
381
    {
382
        $this->file = $file;
383
        return $this;
384
    }
385
    public function getFile()
386
    {
387
        return $this->file;
388
    }
389
    public function setAlternativeFile(File $alternative_file = null)
390
    {
391
        $this->alternativeFile = $alternative_file;
392
        return $this;
393
    }
394
    public function getAlternativeFile()
395
    {
396
        return $this->alternativeFile;
397
    }
398
    public function getBackgroundFile()
399
    {
400
        return $this->backgroundFile;
401
    }
402
    public function setBackgroundFile(File $backgroundFile = null)
403
    {
404
        $this->backgroundFile = $backgroundFile;
405
        return $this;
406
    }
407
    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...
408
    {
409
        $this->language = $language;
410
        return $this;
411
    }
412
    public function getLanguage()
413
    {
414
        return $this->language;
415
    }
416
417
    public function getRegisterDate(): \DateTimeInterface
418
    {
419
        return $this->registerDate;
420
    }
421
    public function setRegisterDate(\DateTimeInterface $registerDate): self
422
    {
423
        $this->registerDate = $registerDate;
424
        return $this;
425
    }
426
    /**
427
     * Add document.
428
     *
429
     * @return Document
430
     */
431
    public function addDocument(Document $document)
432
    {
433
        $this->document[] = $document;
434
        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...
435
    }
436
    /**
437
     * Add company.
438
     *
439
     * @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...
440
     */
441
    public function addCompany(People $company)
442
    {
443
        $this->company[] = $company;
444
        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...
445
    }
446
    /**
447
     * Remove company.
448
     */
449
    public function removeCompany(People $company)
450
    {
451
        $this->company->removeElement($company);
452
    }
453
    /**
454
     * Get company.
455
     *
456
     * @return Collection
457
     */
458
    public function getCompany()
459
    {
460
        return $this->company;
461
    }
462
    /**
463
     * Add link.
464
     *
465
     * @return People
466
     */
467
    public function addLink(People $link)
468
    {
469
        $this->link[] = $link;
470
        return $this;
471
    }
472
    /**
473
     * Remove link.
474
     *
475
     * @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...
476
     */
477
    public function removeLink(People $link)
478
    {
479
        $this->link->removeElement($link);
480
    }
481
    /**
482
     * Get link.
483
     *
484
     * @return Collection
485
     */
486
    public function getLink()
487
    {
488
        return $this->link;
489
    }
490
    /**
491
     * Add user.
492
     *
493
     * @return People
494
     */
495
    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...
496
    {
497
        $this->user[] = $user;
498
        return $this;
499
    }
500
    /**
501
     * Remove user.
502
     */
503
    public function removeUser(\ControleOnline\Entity\User $user)
504
    {
505
        $this->user->removeElement($user);
506
    }
507
    /**
508
     * Get user.
509
     *
510
     * @return Collection
511
     */
512
    public function getUser()
513
    {
514
        return $this->user;
515
    }
516
    /**
517
     * Get document.
518
     *
519
     * @return Collection
520
     */
521
    public function getDocument()
522
    {
523
        return $this->document;
524
    }
525
    /**
526
     * Get address.
527
     *
528
     * @return Collection
529
     */
530
    public function getAddress()
531
    {
532
        return $this->address;
533
    }
534
    /**
535
     * Get document.
536
     *
537
     * @return Collection
538
     */
539
    public function getPhone()
540
    {
541
        return $this->phone;
542
    }
543
    /**
544
     * Get email.
545
     *
546
     * @return Collection
547
     */
548
    public function getEmail()
549
    {
550
        return $this->email;
551
    }
552
    public function getContractsPeople(): Collection
553
    {
554
        return $this->contractsPeople;
555
    }
556
    public function getFoundationDate(): ?\DateTime
557
    {
558
        return $this->foundationDate;
559
    }
560
    public function setFoundationDate(\DateTimeInterface $date): self
561
    {
562
        $this->foundationDate = $date;
563
        return $this;
564
    }
565
    public function getFullName(): string
566
    {
567
        if ($this->getPeopleType() == 'F') {
568
            return trim(preg_replace('/[^A-Za-z\s]/', '', sprintf('%s %s', $this->getName(), $this->getAlias())));
569
        }
570
        return trim(preg_replace('/[^A-Za-z\s]/', '', $this->getName()));
571
    }
572
    public function isPerson(): bool
573
    {
574
        return $this->getPeopleType() == 'F';
575
    }
576
    public function getOneEmail(): ?Email
577
    {
578
        if (($email = $this->getEmail()->first()) === false) {
579
            return null;
580
        }
581
        return $email;
582
    }
583
    public function getOneDocument(): ?Document
584
    {
585
        $documents = $this->getDocument()->filter(function ($peopleDocument) {
586
            if ($peopleDocument->getPeople()->getPeopleType() == 'F') {
587
                return $peopleDocument->getDocumentType()->getDocumentType() == 'CPF';
588
            }
589
            return $peopleDocument->getDocumentType()->getDocumentType() == 'CNPJ';
590
        });
591
        return ($document = $documents->first()) === false ? null : $document;
592
    }
593
    public function getBirthdayAsString(): ?string
594
    {
595
        if ($this->getFoundationDate() instanceof \DateTimeInterface) {
596
            return $this->getFoundationDate()->format('Y-m-d');
597
        }
598
        return null;
599
    }
600
    /**
601
     * Get otherInformations
602
     *
603
     * @return stdClass
604
     */
605
    public function getOtherInformations($decode = false)
606
    {
607
        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...
608
    }
609
    /**
610
     * Set comments
611
     *
612
     * @param string $otherInformations
613
     * @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...
614
     */
615
    public function addOtherInformations($key, $value)
616
    {
617
        $otherInformations = $this->getOtherInformations(true);
618
        $otherInformations->{$key} = $value;
619
        $this->otherInformations = json_encode($otherInformations);
620
        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...
621
    }
622
    /**
623
     * Set comments
624
     *
625
     * @param string $otherInformations
626
     * @return Order
627
     */
628
    public function setOtherInformations(stdClass $otherInformations)
629
    {
630
        $this->otherInformations = json_encode($otherInformations);
631
        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...
632
    }
633
    /**
634
     * Add Config.
635
     *
636
     * @return People
637
     */
638
    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...
639
    {
640
        $this->config[] = $config;
641
        return $this;
642
    }
643
    /**
644
     * Remove Config.
645
     */
646
    public function removeConfig(\ControleOnline\Entity\Config $config)
647
    {
648
        $this->config->removeElement($config);
649
    }
650
    /**
651
     * Get config.
652
     *
653
     * @return Collection
654
     */
655
    public function getConfig()
656
    {
657
        return $this->config;
658
    }
659
}
660