City::getDistrict()   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
eloc 1
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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\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...
8
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...
9
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...
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 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...
12
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...
13
use ControleOnline\Listener\LogListener;
14
use ControleOnline\Repository\CityRepository;
15
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...
16
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...
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
    ],
24
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
25
    normalizationContext: ['groups' => ['city:read']],
26
    denormalizationContext: ['groups' => ['city:write']]
27
)]
28
#[ApiFilter(filterClass: OrderFilter::class, properties: ['city' => 'ASC'])]
29
#[ApiFilter(
30
    filterClass: SearchFilter::class,
31
    properties: [
32
        'city' => 'partial',
33
        'state.uf' => 'exact'
34
    ]
35
)]
36
#[ORM\Table(name: 'city')]
37
#[ORM\Index(name: 'state_id', columns: ['state_id'])]
38
#[ORM\Index(name: 'seo', columns: ['seo'])]
39
#[ORM\UniqueConstraint(name: 'city', columns: ['city', 'state_id'])]
40
#[ORM\UniqueConstraint(name: 'cod_ibge', columns: ['cod_ibge'])]
41
#[ORM\EntityListeners([LogListener::class])]
42
#[ORM\Entity(repositoryClass: CityRepository::class)]
43
class City
44
{
45
    #[ORM\Column(name: 'id', type: 'integer', nullable: false)]
46
    #[ORM\Id]
47
    #[ORM\GeneratedValue(strategy: 'IDENTITY')]
48
    #[Groups(['city:read', 'logistic:read', 'order_details:read', 'order:write',  'people:read', 'address:read', 'delivery_region:read'])]
49
    private $id;
50
51
    #[ORM\Column(name: 'city', type: 'string', length: 80, nullable: false)]
52
    #[Groups(['city:read', 'logistic:read', 'order_details:read', 'order:write',  'people:read', 'address:read', 'delivery_region:read'])]
53
    private $city;
54
55
    #[ORM\Column(name: 'cod_ibge', type: 'integer', nullable: true)]
56
    #[Groups(['city:read', 'logistic:read', 'order_details:read', 'order:write',  'people:read', 'address:read', 'delivery_region:read'])]
57
    private $cod_ibge;
58
59
    #[ORM\Column(name: 'seo', type: 'boolean', nullable: false)]
60
    private $seo;
61
62
    #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id', nullable: false)]
63
    #[ORM\ManyToOne(targetEntity: State::class, inversedBy: 'city')]
64
    #[Groups(['city:read', 'logistic:read', 'order_details:read', 'order:write',  'people:read', 'address:read', 'delivery_region:read'])]
65
    private $state;
66
67
    #[ORM\OneToMany(targetEntity: District::class, mappedBy: 'city')]
68
    private $district;
69
70
    public function __construct()
71
    {
72
        $this->district = new ArrayCollection();
73
        $this->seo = false;
74
    }
75
76
    public function getId()
77
    {
78
        return $this->id;
79
    }
80
81
    public function setCity($city)
82
    {
83
        $this->city = $city;
84
        return $this;
85
    }
86
87
    public function getCity()
88
    {
89
        return strtoupper($this->city);
90
    }
91
92
    public function setState(State $state = null)
93
    {
94
        $this->state = $state;
95
        return $this;
96
    }
97
98
    public function getState()
99
    {
100
        return $this->state;
101
    }
102
103
    public function addDistrict(District $district)
104
    {
105
        $this->district[] = $district;
106
        return $this;
107
    }
108
109
    public function removeDistrict(District $district)
110
    {
111
        $this->district->removeElement($district);
112
    }
113
114
    public function getDistrict()
115
    {
116
        return $this->district;
117
    }
118
119
    public function setSeo($seo)
120
    {
121
        $this->seo = $seo;
122
        return $this;
123
    }
124
125
    public function getSeo()
126
    {
127
        return $this->seo;
128
    }
129
130
    public function setIbge($cod_ibge)
131
    {
132
        $this->cod_ibge = $cod_ibge;
133
        return $this;
134
    }
135
136
    public function getIbge()
137
    {
138
        return $this->cod_ibge;
139
    }
140
}