Passed
Push — master ( e09dec...e82bb8 )
by Luiz Kim
02:42
created

Spool::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 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
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...
7
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...
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\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...
10
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...
11
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...
12
use ControleOnline\Listener\LogListener;
13
use ControleOnline\Repository\SpoolRepository;
14
use DateTime;
15
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...
16
17
#[ApiResource(
18
    operations: [
19
        new Get(
20
            security: 'is_granted(\'ROLE_CLIENT\')',
21
            normalizationContext: ['groups' => ['spool_item:read']],
22
        ),
23
        new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'),
24
        new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'),
25
    ],
26
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
27
    normalizationContext: ['groups' => ['spool:read']],
28
    denormalizationContext: ['groups' => ['spool:write']]
29
)]
30
#[ApiFilter(filterClass: SearchFilter::class, properties: ['user' => 'exact', 'people' => 'exact'])]
31
#[ORM\Table(name: 'spool')]
32
#[ORM\Index(name: 'device_id_idx', columns: ['device_id'])]
33
#[ORM\Index(name: 'user_id_idx', columns: ['user_id'])]
34
#[ORM\Index(name: 'people_id_idx', columns: ['people_id'])]
35
#[ORM\EntityListeners([LogListener::class])]
36
#[ORM\Entity(repositoryClass: SpoolRepository::class)]
37
38
class Spool
39
{
40
    #[ORM\Column(name: 'id', type: 'integer', nullable: false)]
41
    #[ORM\Id]
42
    #[ORM\GeneratedValue(strategy: 'IDENTITY')]
43
    #[Groups(['spool_item:read', 'spool:read',])]
44
    private $id;
45
46
47
    #[ORM\ManyToOne(targetEntity: Device::class)]
48
    #[ORM\JoinColumn(name: 'device_id', referencedColumnName: 'id')]
49
    #[Groups(['spool_item:read', 'spool:read', 'spool:write'])]
50
    private $device;
51
52
    #[ORM\ManyToOne(targetEntity: User::class)]
53
    #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
54
    #[Groups(['spool_item:read', 'spool:read', 'spool:write'])]
55
    private $user;
56
57
58
    #[ORM\Column(name: 'register_date', type: 'datetime', nullable: false)]
59
    #[Groups(['spool_item:read', 'spool:read', 'spool:write'])]
60
    private $registerDate;
61
62
    #[ORM\JoinColumn(name: 'status_id', referencedColumnName: 'id', nullable: false)]
63
    #[ORM\ManyToOne(targetEntity: Status::class)]
64
    #[Groups(['spool_item:read', 'spool:read', 'spool:write'])]
65
    private $status;
66
67
    #[ORM\JoinColumn(name: 'file_id', referencedColumnName: 'id', nullable: false)]
68
    #[ORM\ManyToOne(targetEntity: File::class)]
69
    #[Groups(['spool_item:read', 'spool:read', 'spool:write'])]
70
    private $file;
71
72
    public function __construct()
73
    {
74
        $this->registerDate = new DateTime('now');
75
    }
76
77
    public function getId()
78
    {
79
        return $this->id;
80
    }
81
82
    public function setUser(User $user): self
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\User 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...
83
    {
84
        $this->user = $user;
85
        return $this;
86
    }
87
88
    public function getUser(): User
89
    {
90
        return $this->user;
91
    }
92
93
    public function setRegisterDate($registerDate): self
94
    {
95
        $this->registerDate = $registerDate;
96
        return $this;
97
    }
98
99
    public function getRegisterDate()
100
    {
101
        return $this->registerDate;
102
    }
103
104
    public function setStatus(Status $status): self
105
    {
106
        $this->status = $status;
107
        return $this;
108
    }
109
110
    public function getStatus(): Status
111
    {
112
        return $this->status;
113
    }
114
115
    public function setFile(File $file): self
116
    {
117
        $this->file = $file;
118
        return $this;
119
    }
120
121
    public function getFile(): File
122
    {
123
        return $this->file;
124
    }
125
126
    /**
127
     * Get the value of device
128
     */
129
    public function getDevice(): Device
130
    {
131
        return $this->device;
132
    }
133
134
    /**
135
     * Set the value of device
136
     */
137
    public function setDevice(Device $device): self
138
    {
139
        $this->device = $device;
140
141
        return $this;
142
    }
143
}
144