Test Failed
Push — issue#666 ( f5ce0d...ce3976 )
by Guilherme
28:08
created

IdCard::setPerson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\CoreBundle\Entity;
12
13
use Doctrine\ORM\Mapping as ORM;
14
use JMS\Serializer\Annotation\Groups;
15
use Symfony\Component\Validator\Constraints as Assert;
16
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
17
use JMS\Serializer\Annotation as JMS;
18
use LoginCidadao\CoreBundle\Model\IdCardInterface;
19
use LoginCidadao\CoreBundle\Model\PersonInterface;
20
use LoginCidadao\ValidationControlBundle\Validator\Constraints as Validators;
21
22
/**
23
 * @ORM\Table(name="id_card",
24
 *   uniqueConstraints={
25
 *     @ORM\UniqueConstraint(name="unique_document", columns={"state_id", "value"}),
26
 *     @ORM\UniqueConstraint(name="unique_document", columns={"state_id", "person_id"})
27
 *   }
28
 * )
29
 * @ORM\Entity(repositoryClass="LoginCidadao\CoreBundle\Entity\IdCardRepository")
30
 * @ORM\HasLifecycleCallbacks
31
 * @UniqueEntity(fields={"state","value"}, message="This document is already in use.")
32
 * @UniqueEntity(fields={"state","person"}, message="You already have an ID Card in this state.")
33
 * @Validators\IdCard
34
 */
35
class IdCard implements IdCardInterface
36
{
37
38
    /**
39
     * @ORM\Column(name="id", type="integer")
40
     * @ORM\Id
41
     * @ORM\GeneratedValue(strategy="AUTO")
42
     */
43
    protected $id;
44
45
    /**
46
     * @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\Person", inversedBy="idCards")
47
     * @ORM\JoinColumn(name="person_id", referencedColumnName="id")
48
     */
49
    protected $person;
50
51
    /**
52
     * @JMS\Expose
53
     * @JMS\Groups({"id_cards"})
54
     * @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\State")
55
     * @ORM\JoinColumn(name="state_id", referencedColumnName="id")
56
     */
57
    protected $state;
58
59
    /**
60
     * @JMS\Expose
61
     * @JMS\Groups({"id_cards"})
62
     * @Assert\Length(min=1,max="80")
63
     * @ORM\Column(name="issuer", type="string", length=80)
64
     */
65
    protected $issuer;
66
67
    /**
68
     * @JMS\Expose
69
     * @JMS\Groups({"id_cards"})
70
     * @Assert\Length(min=1,max="20")
71
     * @ORM\Column(name="value",type="string", length=20)
72
     * @Assert\Regex(
73
     *     pattern="/^[A-Za-z0-9]+$/",
74
     *     message="This field accepts only letters and numbers"
75
     * )
76
     */
77
    protected $value;
78
79
    public function getId()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
80
    {
81
        return $this->id;
82
    }
83
84
    public function setId($id)
85
    {
86
        $this->id = $id;
87
        return $this;
88
    }
89
90 3
    public function setState(State $state)
91
    {
92 3
        $this->state = $state;
93 3
        return $this;
94
    }
95
96 1
    public function setPerson(PersonInterface $person)
97
    {
98 1
        $this->person = $person;
99 1
        return $this;
100
    }
101
102
    public function getPerson()
103
    {
104
        return $this->person;
105
    }
106
107 1
    public function getState()
108
    {
109 1
        return $this->state;
110
    }
111
112
    public function setValue($value)
113
    {
114
        $this->value = $value;
115
        return $this;
116
    }
117
118
    public function getValue()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
119
    {
120
        return $this->value;
121
    }
122
123
    public function setIssuer($issuer)
124
    {
125
        $this->issuer = $issuer;
126
        return $this;
127
    }
128
129
    public function getIssuer()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
130
    {
131
        return $this->issuer;
132
    }
133
134
}
135