Completed
Pull Request — master (#28)
by Valentyn
02:24
created

UserProfile::setAbout()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Users\Entity;
5
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\ORM\Mapping as ORM;
8
use JMS\Serializer\Annotation\ExclusionPolicy;
9
use JMS\Serializer\Annotation\Expose;
10
11
/**
12
 * @ORM\Entity
13
 * @ORM\Table(name="users_profiles")
14
 * @ExclusionPolicy("all")
15
 */
16
class UserProfile
17
{
18
    /**
19
     * @ORM\Id()
20
     * @ORM\GeneratedValue()
21
     * @ORM\Column(type="integer")
22
     */
23
    private $id;
24
25
    /**
26
     * @var $user User
27
     * @ORM\OneToOne(targetEntity="App\Users\Entity\User", inversedBy="profile")
28
     * @ORM\JoinColumn(nullable=false)
29
     */
30
    private $user;
31
32
    /**
33
     * @var $contacts UserProfileContacts[]|ArrayCollection
34
     * @ORM\OneToMany(targetEntity="App\Users\Entity\UserProfileContacts", mappedBy="profile", cascade={"persist", "remove"})
35
     * @ORM\JoinColumn(nullable=true)
36
     * @Expose
37
     */
38
    private $contacts;
39
40
    /**
41
     * @ORM\Column(type="string", length=255, nullable=true)
42
     * @Expose
43
     */
44
    private $first_name;
45
46
    /**
47
     * @ORM\Column(type="string", length=255, nullable=true)
48
     * @Expose
49
     */
50
    private $last_name;
51
52
    /**
53
     * @ORM\Column(type="date", nullable=true)
54
     * @Expose
55
     */
56
    private $birth_date;
57
58
    /**
59
     * @ORM\Column(type="string", length=255, nullable=true)
60
     * @Expose
61
     */
62
    private $about;
63
64
    /**
65
     * @ORM\Column(type="string", length=255, nullable=true)
66
     * @Expose
67
     */
68
    private $public_email;
69
70 30
    public function __construct(User $user)
71
    {
72 30
        $this->user = $user;
73 30
        $this->contacts = new ArrayCollection();
74 30
    }
75
76
    /**
77
     * @return mixed
78
     */
79
    public function getFirstName()
80
    {
81
        return $this->first_name;
82
    }
83
84
    /**
85
     * @param mixed $first_name
86
     * @return UserProfile
87
     */
88
    public function setFirstName($first_name)
89
    {
90
        $this->first_name = $first_name;
91
        return $this;
92
    }
93
94
    /**
95
     * @return mixed
96
     */
97
    public function getLastName()
98
    {
99
        return $this->last_name;
100
    }
101
102
    /**
103
     * @param mixed $last_name
104
     * @return UserProfile
105
     */
106
    public function setLastName($last_name)
107
    {
108
        $this->last_name = $last_name;
109
        return $this;
110
    }
111
112
    /**
113
     * @return mixed
114
     */
115
    public function getAbout()
116
    {
117
        return $this->about;
118
    }
119
120
    /**
121
     * @param mixed $about
122
     * @return UserProfile
123
     */
124
    public function setAbout($about)
125
    {
126
        $this->about = $about;
127
        return $this;
128
    }
129
130
    /**
131
     * @return mixed
132
     */
133
    public function getPublicEmail()
134
    {
135
        return $this->public_email;
136
    }
137
138
    /**
139
     * @param mixed $public_email
140
     * @return UserProfile
141
     */
142
    public function setPublicEmail($public_email)
143
    {
144
        $this->public_email = $public_email;
145
        return $this;
146
    }
147
148
    /**
149
     * @return mixed
150
     */
151 1
    public function getId()
152
    {
153 1
        return $this->id;
154
    }
155
156
    /**
157
     * @return User
158
     */
159 1
    public function getUser(): User
160
    {
161 1
        return $this->user;
162
    }
163
164
    /**
165
     * @return mixed
166
     */
167 2
    public function getBirthDate()
168
    {
169 2
        return $this->birth_date;
170
    }
171
172
    /**
173
     * @param \DateTime $birth_date
174
     * @return UserProfile
175
     */
176 1
    public function setBirthDate(\DateTime $birth_date)
177
    {
178 1
        $this->birth_date = $birth_date;
179 1
        return $this;
180
    }
181
182
    /**
183
     * @return UserProfileContacts[]|ArrayCollection
184
     */
185 2
    public function getContacts()
186
    {
187 2
        return $this->contacts;
188
    }
189
190
    /**
191
     * @param $name
192
     * @param $url
193
     * @return $this
194
     */
195 1
    public function addContacts($name, $url)
196
    {
197 1
        $contact = new UserProfileContacts($this, $name, $url);
198 1
        $this->contacts->add($contact);
199 1
        return $this;
200
    }
201
}