Street::removeAddress()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 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\Metadata\ApiResource;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiResource was not found. Maybe you did not declare it correctly or list all dependencies?

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

filter:
    dependency_paths: ["lib/*"]

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

Loading history...
8
use ApiPlatform\Metadata\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...
9
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...
10
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...
11
use 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...
12
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...
13
use ControleOnline\Entity\District;
14
use ControleOnline\Entity\Cep;
15
use ControleOnline\Entity\Address;
16
use ControleOnline\Repository\StreetRepository;
17
use ControleOnline\Listener\LogListener;
18
19
#[ORM\Table(name: 'street')]
20
#[ORM\Index(name: 'district_id', columns: ['district_id'])]
21
#[ORM\Index(name: 'cep', columns: ['cep_id'])]
22
#[ORM\Index(name: 'street', columns: ['street'])]
23
#[ORM\UniqueConstraint(name: 'street_2', columns: ['street', 'district_id'])]
24
#[ORM\EntityListeners([LogListener::class])]
25
#[ORM\Entity(repositoryClass: StreetRepository::class)]
26
#[ApiResource(
27
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
28
    normalizationContext: ['groups' => ['street:read']],
29
    denormalizationContext: ['groups' => ['street:write']],
30
    operations: [
31
        new GetCollection(security: "is_granted('ROLE_CLIENT')"),
32
        new Get(security: "is_granted('ROLE_CLIENT')")
33
    ]
34
)]
35
class Street
36
{
37
    #[ORM\Column(name: 'id', type: 'integer', nullable: false)]
38
    #[ORM\Id]
39
    #[ORM\GeneratedValue(strategy: 'IDENTITY')]
40
    #[Groups(['people:read', 'order_details:read', 'order:write',  'address:read'])]
41
    private $id;
42
43
    #[ORM\Column(name: 'street', type: 'string', length: 255, nullable: false)]
44
    #[Groups(['people:read', 'order_details:read', 'order:write',  'address:read'])]
45
    private $street;
46
47
    #[ORM\ManyToOne(targetEntity: District::class, inversedBy: 'street')]
48
    #[ORM\JoinColumn(name: 'district_id', referencedColumnName: 'id', nullable: false)]
49
    #[Groups(['people:read', 'order_details:read', 'order:write',  'address:read'])]
50
    private $district;
51
52
    #[ORM\ManyToOne(targetEntity: Cep::class, inversedBy: 'street')]
53
    #[ORM\JoinColumn(name: 'cep_id', referencedColumnName: 'id', nullable: false)]
54
    #[Groups(['people:read', 'order_details:read', 'order:write',  'address:read'])]
55
    private $cep;
56
57
    #[ORM\OneToMany(targetEntity: Address::class, mappedBy: 'street')]
58
    private $address;
59
60
    #[ORM\Column(name: 'confirmed', type: 'boolean', nullable: true)]
61
    private $confirmed;
62
63
    public function __construct()
64
    {
65
        $this->address = new ArrayCollection();
66
    }
67
68
    public function getId()
69
    {
70
        return $this->id;
71
    }
72
73
    public function setStreet($street)
74
    {
75
        $this->street = $street;
76
        return $this;
77
    }
78
79
    public function getStreet()
80
    {
81
        return strtoupper($this->street);
82
    }
83
84
    public function setDistrict(District $district = null)
85
    {
86
        $this->district = $district;
87
        return $this;
88
    }
89
90
    public function getDistrict()
91
    {
92
        return $this->district;
93
    }
94
95
    public function setCep(Cep $cep = null)
96
    {
97
        $this->cep = $cep;
98
        return $this;
99
    }
100
101
    public function getCep()
102
    {
103
        return $this->cep;
104
    }
105
106
    public function addAddress(Address $address)
107
    {
108
        $this->address[] = $address;
109
        return $this;
110
    }
111
112
    public function removeAddress(Address $address)
113
    {
114
        $this->address->removeElement($address);
115
    }
116
117
    public function getAddress()
118
    {
119
        return $this->address;
120
    }
121
122
    public function setConfirmed($confirmed)
123
    {
124
        $this->confirmed = $confirmed;
125
        return $this;
126
    }
127
128
    public function getConfirmed()
129
    {
130
        return $this->confirmed;
131
    }
132
}
133