Passed
Push — master ( 64d74b...3b331f )
by Luiz Kim
07:22 queued 05:09
created

File::setExtension()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace ControleOnline\Entity;
4
5
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...
6
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...
7
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...
8
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...
9
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...
10
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...
11
use App\Controller\GetFileDataAction;
0 ignored issues
show
Bug introduced by
The type App\Controller\GetFileDataAction 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\FileUploadController;
13
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...
14
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...
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 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...
18
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\ExistsFilter 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...
19
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...
20
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...
21
22
23
/**
24
 * File
25
 *
26
 * @ORM\EntityListeners ({ControleOnline\Listener\LogListener::class})
27
 * @ORM\Entity (repositoryClass="ControleOnline\Repository\FileRepository")
28
 * @ORM\Table (name="files", uniqueConstraints={@ORM\UniqueConstraint (name="url", columns={"url"}), @ORM\UniqueConstraint(name="path", columns={"path"})})
29
 */
30
#[ApiResource(
31
    operations: [
32
        new Get(security: 'is_granted(\'ROLE_CLIENT\')'),
33
        new Get(
34
            security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')',
35
            uriTemplate: '/files/download/{id}',
36
            controller: GetFileDataAction::class
37
        ),
38
        new Post(
39
            security: 'is_granted(\'ROLE_CLIENT\')',
40
            uriTemplate: '/files/upload',
41
            controller: FileUploadController::class,
42
            deserialize: false
43
        ),
44
        new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')')
45
    ],
46
47
    normalizationContext: ['groups' => ['file_read']],
48
    denormalizationContext: ['groups' => ['file_write']]
49
)]
50
class File
51
{
52
    /**
53
     *
54
     * @ORM\Column(type="integer", nullable=false)
55
     * @ORM\Id
56
     * @ORM\GeneratedValue(strategy="IDENTITY")
57
     * @Groups({"file_read","people_read"})
58
     */
59
    private $id;
60
61
    /**
62
     * @ORM\Column(type="string", length=255, nullable=false)
63
     * @Groups({"file_read","people_read"})
64
     * @Assert\NotBlank
65
     */
66
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['file_type' => 'exact'])]
67
    private $file_type;
68
69
    /**
70
     * @ORM\Column(type="string", length=255, nullable=false)
71
     * @Groups({"file_read","people_read"})
72
     * @Assert\NotBlank
73
     */
74
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['file_name' => 'exact'])]
75
    private $file_name;
76
77
    /**
78
     * @ORM\Column(type="string", length=255, nullable=false)
79
     * @Groups({"file_read","people_read"})
80
     * @Assert\NotBlank
81
     */
82
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['extension' => 'exact'])]
83
    private $extension;
84
85
    /**
86
     * @ORM\Column(type="string", length=255, nullable=false)
87
     */
88
    private $content;
89
90
91
    /**
92
     * @var \ControleOnline\Entity\People
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\People 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...
93
     *
94
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People")
95
     * @ORM\JoinColumns({
96
     *   @ORM\JoinColumn(name="people_id", referencedColumnName="id")
97
     * })
98
     * @Groups({"file_read"})
99
     */
100
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])]
101
102
    private $people;
103
104
    public function __construct()
105
    {
106
        $this->people = new \Doctrine\Common\Collections\ArrayCollection();
107
    }
108
109
    public function getId()
110
    {
111
        return $this->id;
112
    }
113
114
115
116
    /**
117
     * Get the value of file_type
118
     */
119
    public function getFileType()
120
    {
121
        return $this->file_type;
122
    }
123
124
    /**
125
     * Set the value of file_type
126
     */
127
    public function setFileType($file_type): self
128
    {
129
        $this->file_type = $file_type;
130
131
        return $this;
132
    }
133
134
    /**
135
     * Get the value of content
136
     */
137
    public function getContent()
138
    {
139
        return $this->content;
140
    }
141
142
    /**
143
     * Set the value of content
144
     */
145
    public function setContent($content): self
146
    {
147
        $this->content = $content;
148
149
        return $this;
150
    }
151
152
    /**
153
     * Get the value of people
154
     */
155
    public function getPeople()
156
    {
157
        return $this->people;
158
    }
159
160
    /**
161
     * Set the value of people
162
     */
163
    public function setPeople($people): self
164
    {
165
        $this->people = $people;
166
167
        return $this;
168
    }
169
170
    /**
171
     * Get the value of extension
172
     */
173
    public function getExtension()
174
    {
175
        return $this->extension;
176
    }
177
178
    /**
179
     * Set the value of extension
180
     */
181
    public function setExtension($extension): self
182
    {
183
        $this->extension = $extension;
184
185
        return $this;
186
    }
187
188
    /**
189
     * Get the value of file_name
190
     */
191
    public function getFileName()
192
    {
193
        return $this->file_name;
194
    }
195
196
    /**
197
     * Set the value of file_name
198
     */
199
    public function setFileName($file_name): self
200
    {
201
        $this->file_name = $file_name;
202
203
        return $this;
204
    }
205
}
206