Device   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Importance

Changes 8
Bugs 0 Features 0
Metric Value
wmc 5
eloc 46
c 8
b 0
f 0
dl 0
loc 80
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setAlias() 0 5 1
A getAlias() 0 3 1
A setDevice() 0 4 1
A getId() 0 3 1
A getDevice() 0 3 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 ControleOnline\Repository\DeviceRepository;
8
use ControleOnline\Listener\LogListener;
9
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...
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 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...
12
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...
13
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...
14
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...
15
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...
16
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...
17
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...
18
use ControleOnline\DataProvider\PrinterDataProvider;
19
use Doctrine\ORM\Mapping\Column;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping\Column 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 Doctrine\ORM\Mapping\Entity;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping\Entity 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
use Doctrine\ORM\Mapping\EntityListeners;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping\EntityListeners 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...
22
use Doctrine\ORM\Mapping\GeneratedValue;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping\GeneratedValue 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...
23
use Doctrine\ORM\Mapping\Id;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping\Id 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...
24
use Doctrine\ORM\Mapping\Table;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping\Table 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...
25
use Symfony\Component\Validator\Constraints\NotBlank;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Validator\Constraints\NotBlank 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...
26
27
#[ApiResource(
28
    operations: [
29
        new Get(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')'),
30
        new Put(
31
            security: 'is_granted(\'ROLE_CLIENT\')',
32
            denormalizationContext: ['groups' => ['device:write']]
33
        ),
34
        new Delete(security: 'is_granted(\'ROLE_CLIENT\')'),
35
        new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'),
36
        new GetCollection(
37
            security: 'is_granted(\'PUBLIC_ACCESS\')',
38
        ),
39
        new GetCollection(
40
            security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')',
41
            uriTemplate: '/printers',
42
            provider: PrinterDataProvider::class,
43
            normalizationContext: ['groups' => ['device:read']],
44
        ),
45
    ],
46
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
47
    normalizationContext: ['groups' => ['device:read']],
48
    denormalizationContext: ['groups' => ['device:write']]
49
)]
50
#[ApiFilter(filterClass: OrderFilter::class, properties: ['id' => 'ASC'])]
51
#[Table(name: 'device')]
52
#[EntityListeners([LogListener::class])]
53
#[Entity(repositoryClass: DeviceRepository::class)]
54
class Device
55
{
56
    #[Groups(['device_config:read', 'device:read', 'spool_item:read', 'spool:read', 'spool:write', 'device:write'])]
57
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
58
    #[Column(name: 'id', type: 'integer', nullable: false)]
59
    #[Id]
60
    #[GeneratedValue(strategy: 'IDENTITY')]
61
    private int $id = 0;
62
63
    #[Groups(['device_config:read', 'device:read', 'spool_item:read', 'spool:read', 'spool:write', 'device:write'])]
64
    #[NotBlank]
65
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['device' => 'exact'])]
66
    #[Column(name: 'device', type: 'string', length: 100, nullable: false)]
67
    private string $device = '';
68
69
    #[Groups(['device_config:read', 'device:read', 'spool_item:read', 'spool:read', 'spool:write', 'device:write'])]
70
    #[NotBlank]
71
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['alias' => 'exact'])]
72
    #[Column(name: 'alias', type: 'string', length: 100, nullable: true)]
73
    private string $alias = '';
74
75
    public function getId(): int
76
    {
77
        return $this->id;
78
    }
79
80
    public function getDevice(): string
81
    {
82
        return $this->device;
83
    }
84
85
    public function setDevice(string $device): self
86
    {
87
        $this->device = $device;
88
        return $this;
89
    }
90
91
    /**
92
     * Get the value of alias
93
     */
94
    public function getAlias(): ?string
95
    {
96
        return $this->alias;
97
    }
98
99
    /**
100
     * Set the value of alias
101
     */
102
    public function setAlias(string | null $alias): self
103
    {
104
        $this->alias = $alias;
105
106
        return $this;
107
    }
108
}
109