Email::getPeople()   A
last analyzed

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 Symfony\Component\Serializer\Attribute\Groups;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Serializer\Attribute\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...
6
7
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...
8
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...
9
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...
10
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...
11
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...
12
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...
13
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...
14
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...
15
use ControleOnline\Listener\LogListener;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Listener\LogListener 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 ControleOnline\Repository\EmailRepository;
17
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...
18
19
#[ApiResource(
20
    operations: [
21
        new Get(security: 'is_granted(\'ROLE_CLIENT\')'),
22
        new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'),
23
        new Put(
24
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
25
            validationContext: ['groups' => ['email:read']],
26
            denormalizationContext: ['groups' => ['email:write']]
27
        ),
28
        new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'),
29
        new Delete(security: "is_granted(\'ROLE_CLIENT\')")
30
    ],
31
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
32
    normalizationContext: ['groups' => ['email:read']],
33
    denormalizationContext: ['groups' => ['email:write']]
34
)]
35
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])]
36
#[ORM\Table(name: 'email')]
37
#[ORM\Index(columns: ['people_id'])]
38
#[ORM\UniqueConstraint(name: 'email', columns: ['email'])]
39
#[ORM\EntityListeners([LogListener::class])]
40
#[ORM\Entity(repositoryClass: EmailRepository::class)]
41
class Email
42
{
43
    #[ORM\Column(type: 'integer', nullable: false)]
44
    #[ORM\Id]
45
    #[ORM\GeneratedValue(strategy: 'IDENTITY')]
46
    private int $id = 0;
47
48
    #[ORM\Column(type: 'string', length: 50, nullable: false)]
49
    #[Groups(['invoice_details:read', 'order_details:read', 'order:write', 'people:read', 'email:read', 'get_contracts', 'carrier:read', 'email:write'])]
50
    private string $email;
51
52
    #[ORM\Column(type: 'boolean', nullable: false)]
53
    private bool $confirmed = false;
54
55
    #[ORM\Column(type: 'string', length: 50, nullable: true)]
56
    #[Groups(['invoice_details:read', 'order_details:read', 'order:write', 'people:read', 'email:read', 'get_contracts', 'carrier:read'])]
57
    private ?string $types = null;
58
59
    #[ORM\JoinColumn(name: 'people_id', referencedColumnName: 'id')]
60
    #[ORM\ManyToOne(targetEntity: People::class, inversedBy: 'email')]
61
    #[Groups(['email:read'])]
62
    private ?People $people = null;
63
64
    public function getId(): int
65
    {
66
        return $this->id;
67
    }
68
69
    public function setEmail(string $email): self
70
    {
71
        $this->email = trim($email);
72
        return $this;
73
    }
74
75
    public function getEmail(): string
76
    {
77
        return $this->email;
78
    }
79
80
    public function getTypes(): object
81
    {
82
        return $this->types ? json_decode($this->types) : new \stdClass();
83
    }
84
85
    public function addType(string $key, mixed $value): self
86
    {
87
        $types = $this->getTypes();
88
        $types->$key = $value;
89
        $this->types = json_encode($types);
90
        return $this;
91
    }
92
93
    public function setTypes(object $types): self
94
    {
95
        $this->types = json_encode($types);
96
        return $this;
97
    }
98
99
    public function setConfirmed(bool $confirmed): self
100
    {
101
        $this->confirmed = $confirmed;
102
        return $this;
103
    }
104
105
    public function getConfirmed(): bool
106
    {
107
        return $this->confirmed;
108
    }
109
110
    public function setPeople(?People $people): self
111
    {
112
        $this->people = $people;
113
        return $this;
114
    }
115
116
    public function getPeople(): ?People
117
    {
118
        return $this->people;
119
    }
120
}