Email   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 11
eloc 52
c 4
b 0
f 0
dl 0
loc 101
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A setPeople() 0 4 1
A getConfirmed() 0 3 1
A getEmail() 0 3 1
A setEmail() 0 4 1
A addType() 0 6 1
A getTypes() 0 3 2
A setConfirmed() 0 4 1
A getPeople() 0 3 1
A setTypes() 0 4 1
A getId() 0 3 1
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
36
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])]
37
#[ORM\Table(name: 'email')]
38
#[ORM\Index(columns: ['people_id'])]
39
#[ORM\UniqueConstraint(name: 'email', columns: ['email'])]
40
41
#[ORM\Entity(repositoryClass: EmailRepository::class)]
42
class Email
43
{
44
    #[ORM\Column(type: 'integer', nullable: false)]
45
    #[ORM\Id]
46
    #[ORM\GeneratedValue(strategy: 'IDENTITY')]
47
    private int $id = 0;
48
49
    #[ORM\Column(type: 'string', length: 50, nullable: false)]
50
    #[Groups(['invoice_details:read', 'order_details:read', 'order:write', 'people:read', 'email:read', 'get_contracts', 'carrier:read', 'email:write'])]
51
    private string $email;
52
53
    #[ORM\Column(type: 'boolean', nullable: false)]
54
    private bool $confirmed = false;
55
56
    #[ORM\Column(type: 'string', length: 50, nullable: true)]
57
    #[Groups(['invoice_details:read', 'order_details:read', 'order:write', 'people:read', 'email:read', 'get_contracts', 'carrier:read'])]
58
    private ?string $types = null;
59
60
    #[ORM\JoinColumn(name: 'people_id', referencedColumnName: 'id')]
61
    #[ORM\ManyToOne(targetEntity: People::class, inversedBy: 'email')]
62
    #[Groups(['connections:read', 'email:read', 'email:write'])]
63
    private ?People $people = null;
64
65
    public function getId(): int
66
    {
67
        return $this->id;
68
    }
69
70
    public function setEmail(string $email): self
71
    {
72
        $this->email = trim($email);
73
        return $this;
74
    }
75
76
    public function getEmail(): string
77
    {
78
        return $this->email;
79
    }
80
81
    public function getTypes(): object
82
    {
83
        return $this->types ? json_decode($this->types) : new \stdClass();
84
    }
85
86
    public function addType(string $key, mixed $value): self
87
    {
88
        $types = $this->getTypes();
89
        $types->$key = $value;
90
        $this->types = json_encode($types);
91
        return $this;
92
    }
93
94
    public function setTypes(object $types): self
95
    {
96
        $this->types = json_encode($types);
97
        return $this;
98
    }
99
100
    public function setConfirmed(bool $confirmed): self
101
    {
102
        $this->confirmed = $confirmed;
103
        return $this;
104
    }
105
106
    public function getConfirmed(): bool
107
    {
108
        return $this->confirmed;
109
    }
110
111
    public function setPeople(?People $people): self
112
    {
113
        $this->people = $people;
114
        return $this;
115
    }
116
117
    public function getPeople(): ?People
118
    {
119
        return $this->people;
120
    }
121
}