Passed
Push — master ( a91459...e52b22 )
by Luiz Kim
02:52
created

CategoryFile   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 26
c 1
b 0
f 0
dl 0
loc 96
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A getFile() 0 3 1
A setCategory() 0 5 1
A getCategory() 0 3 1
A setFile() 0 5 1
1
<?php
2
3
namespace ControleOnline\Entity;
4
5
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...
6
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...
7
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...
8
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...
9
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...
10
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...
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\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...
13
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...
14
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...
15
16
17
/**
18
 * CategoryFile
19
 *
20
 * @ORM\Table(name="category_file", uniqueConstraints={@ORM\UniqueConstraint(name="category_id", columns={"category_id", "file_id"})}, indexes={@ORM\Index(name="file_id", columns={"file_id"}), @ORM\Index(name="IDX_CDFC73564584665B", columns={"category_id"})})
21
 * @ORM\Entity(repositoryClass="ControleOnline\Repository\CategoryFileRepository")
22
 */
23
24
#[ApiResource(
25
    operations: [
26
        new Get(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')'),
27
        new Put(
28
            security: 'is_granted(\'ROLE_CLIENT\')',
29
            denormalizationContext: ['groups' => ['category_file:write']]
30
        ),
31
        new Delete(security: 'is_granted(\'ROLE_CLIENT\')'),
32
        new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'),
33
        new GetCollection(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')')
34
    ],
35
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
36
    normalizationContext: ['groups' => ['category_file:read']],
37
    denormalizationContext: ['groups' => ['category_file:write']]
38
)]
39
class CategoryFile
40
{
41
    /**
42
     * @var int
43
     *
44
     * @ORM\Column(name="id", type="integer", nullable=false)
45
     * @ORM\Id
46
     * @ORM\GeneratedValue(strategy="IDENTITY")
47
     * @Groups({"category:read","category_file:read"})
48
     */
49
    private $id;
50
51
    /**
52
     * @var ControleOnline\Entity\File
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\ControleOnline\Entity\File was not found. Did you mean ControleOnline\Entity\File? If so, make sure to prefix the type with \.
Loading history...
53
     *
54
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File")
55
     * @ORM\JoinColumns({
56
     *   @ORM\JoinColumn(name="file_id", referencedColumnName="id")
57
     * })
58
     * @Groups({"category:read","category_file:read","category_file:write"})
59
     */
60
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['file' => 'exact'])]
61
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['file.fileType' => 'exact'])]
62
63
    private $file;
64
65
    /**
66
     * @var Category
67
     *
68
     * @ORM\ManyToOne(targetEntity="Category")
69
     * @ORM\JoinColumns({
70
     *   @ORM\JoinColumn(name="category_id", referencedColumnName="id")
71
     * })
72
     * @Groups({"category_file:read","category_file:write"})
73
     */
74
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['category' => 'exact'])]
75
76
    private $category;
77
78
    /**
79
     * Get the value of id
80
     */
81
    public function getId(): int
82
    {
83
        return $this->id;
84
    }
85
86
    /**
87
     * Get the value of file
88
     */
89
    public function getFile(): File
90
    {
91
        return $this->file;
92
    }
93
94
    /**
95
     * Set the value of file
96
     */
97
    public function setFile(File $file): self
98
    {
99
        $this->file = $file;
0 ignored issues
show
Documentation Bug introduced by
It seems like $file of type ControleOnline\Entity\File is incompatible with the declared type ControleOnline\Entity\ControleOnline\Entity\File of property $file.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
100
101
        return $this;
102
    }
103
104
    /**
105
     * Get the value of category
106
     */
107
    public function getCategory(): Category
108
    {
109
        return $this->category;
110
    }
111
112
    /**
113
     * Set the value of category
114
     */
115
    public function setCategory(Category $category): self
116
    {
117
        $this->category = $category;
118
119
        return $this;
120
    }
121
}
122