ExtraData   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 10
eloc 55
c 2
b 0
f 0
dl 0
loc 106
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A setEntityName() 0 4 1
A getEntityId() 0 3 1
A setValue() 0 4 1
A getId() 0 3 1
A getExtraFields() 0 3 1
A getEntityName() 0 3 1
A setEntityId() 0 4 1
A setExtraFields() 0 4 1
A getValue() 0 3 1
A __construct() 0 2 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\ExtraDataRepository;
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\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...
17
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...
18
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...
19
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...
20
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...
21
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...
22
use Doctrine\ORM\Mapping\JoinColumn;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping\JoinColumn 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\ManyToOne;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping\ManyToOne 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
26
#[ApiResource(
27
    operations: [
28
        new Get(uriTemplate: '/extra_data/{id}', security: 'is_granted(\'ROLE_CLIENT\')'),
29
        new GetCollection(uriTemplate: '/extra_data', security: 'is_granted(\'ROLE_CLIENT\')'),
30
        new Put(
31
            uriTemplate: '/extra_data/{id}',
32
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
33
            validationContext: ['groups' => ['extra_data:write']],
34
            denormalizationContext: ['groups' => ['extra_data:write']]
35
        ),
36
        new Delete(uriTemplate: '/extra_data/{id}', security: 'is_granted(\'ROLE_CLIENT\')'),
37
        new Post(uriTemplate: '/extra_data', securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'),
38
    ],
39
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
40
    normalizationContext: ['groups' => ['extra_data:read']],
41
    denormalizationContext: ['groups' => ['extra_data:write']]
42
)]
43
#[ApiFilter(filterClass: SearchFilter::class, properties: [
44
    'id' => 'exact',
45
    'extra_fields' => 'exact',
46
    'entity_id' => 'exact',
47
    'entity_name' => 'exact',
48
    // 'people' filter seems out of place as there's no 'people' property,
49
    // unless it relates to ExtraFields or another implicit context.
50
    // Keeping it based on the original code, but review if it's functional.
51
    'people' => 'exact'
52
])]
53
#[Table(name: 'extra_data')]
54
#[EntityListeners([LogListener::class])]
55
#[Entity(repositoryClass: ExtraDataRepository::class)]
56
class ExtraData
57
{
58
    #[Groups(['extrafields:read', 'extra_data:read'])]
59
    #[Column(name: 'id', type: 'integer', nullable: false)]
60
    #[Id]
61
    #[GeneratedValue(strategy: 'IDENTITY')]
62
    private int $id = 0;
63
64
    #[Groups(['extra_data:read'])]
65
    #[JoinColumn(name: 'extra_fields_id', referencedColumnName: 'id', nullable: true)] // Assuming nullable based on lack of 'nullable: false'
66
    #[ManyToOne(targetEntity: ExtraFields::class)]
67
    private ?ExtraFields $extra_fields = null;
68
69
    #[Groups(['extra_data:read'])]
70
    #[Column(name: 'entity_id', type: 'string', nullable: false)]
71
    private string $entity_id;
72
73
    #[Groups(['extra_data:read'])]
74
    #[Column(name: 'entity_name', type: 'string', nullable: false)]
75
    private string $entity_name;
76
77
    #[Groups(['extra_data:read'])]
78
    #[Column(name: 'data_value', type: 'string', nullable: false)]
79
    private string $value;
80
81
    public function __construct()
82
    {
83
    }
84
85
    public function getId(): int
86
    {
87
        return $this->id;
88
    }
89
90
    public function setValue(string $value): self
91
    {
92
        $this->value = $value;
93
        return $this;
94
    }
95
96
    public function getValue(): string
97
    {
98
        return $this->value;
99
    }
100
101
    public function getEntityId(): string
102
    {
103
        return $this->entity_id;
104
    }
105
106
    public function setEntityId(int | string $entity_id): self
107
    {
108
        $this->entity_id = $entity_id;
109
        return $this;
110
    }
111
112
    public function getEntityName(): string
113
    {
114
        return $this->entity_name;
115
    }
116
117
    public function setEntityName(string $entity_name): self
118
    {
119
        $this->entity_name = $entity_name;
120
        return $this;
121
    }
122
123
    public function getExtraFields(): ?ExtraFields
124
    {
125
        return $this->extra_fields;
126
    }
127
128
    public function setExtraFields(?ExtraFields $extra_fields): self
129
    {
130
        $this->extra_fields = $extra_fields;
131
        return $this;
132
    }
133
}