Passed
Push — master ( fabd2b...70cc07 )
by Luiz Kim
02:32
created

Device::setConfigs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
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 4
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\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...
7
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...
8
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...
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\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...
11
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...
12
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...
13
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...
14
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...
15
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...
16
use ControleOnline\Filter\CustomOrFilter;
17
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...
18
use stdClass;
19
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...
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
 * @ORM\EntityListeners ({ControleOnline\Listener\LogListener::class})
24
 * @ORM\Table (name="device")
25
 * @ORM\Entity (repositoryClass="ControleOnline\Repository\DeviceRepository")
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(\'IS_AUTHENTICATED_ANONYMOUSLY\')',
38
        )
39
    ],
40
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
41
    normalizationContext: ['groups' => ['device:read']],
42
    denormalizationContext: ['groups' => ['device:write']]
43
)]
44
#[ApiFilter(filterClass: OrderFilter::class, properties: ['id' => 'ASC'])]
45
46
class Device
47
{
48
    /**
49
     * @var integer
50
     *
51
     * @ORM\Column(name="id", type="integer", nullable=false)
52
     * @ORM\Id
53
     * @ORM\GeneratedValue(strategy="IDENTITY")
54
     * @Groups({"device:read","device:write"})
55
     */
56
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
57
58
    private $id;
59
60
61
    /**
62
     * @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...
63
     *
64
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People")
65
     * @ORM\JoinColumns({
66
     *   @ORM\JoinColumn(name="people_id", referencedColumnName="id")
67
     * })
68
     * @Groups({"device:read","device:write"})
69
     */
70
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])]
71
72
    private $people;
73
    /**
74
     * @var string
75
     *
76
     * @ORM\Column(name="store", type="string", length=100, nullable=false)
77
     * @Groups({"device:read","device:write"})
78
     * @Assert\NotBlank
79
     */
80
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['device' => 'exact'])]
81
82
    private $device;
83
84
85
    /**
86
     * @var string
87
     *
88
     * @ORM\Column(name="configs", type="string", length=100, nullable=false)
89
     * @Groups({"device:read","device:write"})
90
     * @Assert\NotBlank
91
     */
92
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['configs' => 'exact'])]
93
94
    private $configs;
95
    public function __construct()
96
    {
97
        $this->configs = json_encode(new stdClass());
98
    }
99
100
    /**
101
     * Get the value of id
102
     */
103
    public function getId()
104
    {
105
        return $this->id;
106
    }
107
108
    /**
109
     * Get the value of people
110
     */
111
    public function getPeople()
112
    {
113
        return $this->people;
114
    }
115
116
    /**
117
     * Set the value of people
118
     */
119
    public function setPeople($people): self
120
    {
121
        $this->people = $people;
122
123
        return $this;
124
    }
125
126
127
    /**
128
     * Get the value of device
129
     */
130
    public function getDevice()
131
    {
132
        return $this->device;
133
    }
134
135
    /**
136
     * Set the value of device
137
     */
138
    public function setDevice($device): self
139
    {
140
        $this->device = $device;
141
142
        return $this;
143
    }
144
145
146
    public function getConfigs($decode = false)
147
    {
148
        return $decode ? (object) json_decode((is_array($this->configs) ? json_encode($this->configs) : $this->configs)) : $this->configs;
0 ignored issues
show
introduced by
The condition is_array($this->configs) is always false.
Loading history...
149
    }
150
151
152
    public function addConfigs($key, $value)
153
    {
154
        $configs = $this->getConfigs(true);
155
        $configs->$key = $value;
156
        $this->configs = json_encode($configs);
157
        return $this;
158
    }
159
160
161
    public function setConfigs($configs)
162
    {
163
        $this->configs = json_encode($configs);
164
        return $this;
165
    }
166
}
167