Passed
Push — master ( 3f8050...70788f )
by Luiz Kim
05:05 queued 02:57
created

Email::setPeople()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
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\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...
7
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...
8
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...
9
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...
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 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...
12
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...
13
use Doctrine\Common\Collections\ArrayCollection;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\ArrayCollection 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 Doctrine\Common\Collections\Collection;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\Collection 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 stdClass;
16
17
/**
18
 * Email
19
 *
20
 * @ORM\EntityListeners ({App\Listener\LogListener::class})
21
 * @ORM\Entity (repositoryClass="ControleOnline\Repository\EmailRepository")
22
 * @ORM\Table (name="email", uniqueConstraints={@ORM\UniqueConstraint (name="email", columns={"email"})}, indexes={@ORM\Index (columns={"people_id"})})
23
 */
24
#[ApiResource(
25
    operations: [
26
        new Get(security: 'is_granted(\'ROLE_CLIENT\')'),
27
        new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'),
28
        new GetCollection(
29
            uriTemplate: '/email/find',
30
            controller: \App\Controller\SearchEmailAction::class
31
        )
32
    ],
33
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
34
    normalizationContext: ['groups' => ['email_read']],
35
    denormalizationContext: ['groups' => ['email_write']]
36
)]
37
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])]
38
class Email
39
{
40
    /**
41
     * @ORM\Column(type="integer", nullable=false)
42
     * @ORM\Id
43
     * @ORM\GeneratedValue(strategy="IDENTITY")
44
     */
45
    private $id;
46
    /**
47
     *
48
     * @ORM\Column(type="string", length=50, nullable=false)
49
     * @Groups({"people_read", "email_read",  "get_contracts", "carrier_read"})
50
     */
51
    private $email;
52
    /**
53
     * @ORM\Column(type="boolean", nullable=false)
54
     */
55
    private $confirmed = false;
56
    /**
57
     *
58
     * @ORM\Column(type="string", length=50, nullable=true)
59
     * @Groups({"people_read", "email_read",  "get_contracts", "carrier_read"})
60
     */
61
    private $types = false;
62
    /**
63
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People", inversedBy="email")
64
     * @ORM\JoinColumns({
65
     *   @ORM\JoinColumn(name="people_id", referencedColumnName="id")
66
     * })
67
     * @Groups({"email_read"})
68
     */
69
    private $people;
70
    public function getId()
71
    {
72
        return $this->id;
73
    }
74
    public function setEmail($email)
75
    {
76
        $this->email = trim($email);
77
        return $this;
78
    }
79
    public function getEmail()
80
    {
81
        return $this->email;
82
    }
83
    /**
84
     * Get otherInformations
85
     *
86
     * @return stdClass
87
     */
88
    public function getTypes()
89
    {
90
        return count((array) $this->types) > 0 ? json_decode($this->types) : new stdClass();
0 ignored issues
show
Bug introduced by
It seems like $this->types can also be of type null; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

90
        return count((array) $this->types) > 0 ? json_decode(/** @scrutinizer ignore-type */ $this->types) : new stdClass();
Loading history...
91
    }
92
    /**
93
     * Set comments
94
     *
95
     * @param string $type
96
     * @return Email
97
     */
98
    public function addType($key, $value)
99
    {
100
        $types = $this->getTypes();
101
        $types->{$key} = $value;
102
        $this->types = json_encode($types);
103
        return $this;
104
    }
105
    /**
106
     * Set comments
107
     *
108
     * @param string $otherInformations
109
     * @return Order
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Order 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...
110
     */
111
    public function setTypes(stdClass $types)
112
    {
113
        $this->types = json_encode($types);
114
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type ControleOnline\Entity\Email which is incompatible with the documented return type ControleOnline\Entity\Order.
Loading history...
115
    }
116
    public function setConfirmed($confirmed)
117
    {
118
        $this->confirmed = $confirmed;
119
        return $this;
120
    }
121
    public function getConfirmed()
122
    {
123
        return $this->confirmed;
124
    }
125
    public function setPeople(People $people = null)
126
    {
127
        $this->people = $people;
128
        return $this;
129
    }
130
    public function getPeople()
131
    {
132
        return $this->people;
133
    }
134
}
135