Completed
Pull Request — master (#26)
by Valentyn
02:41
created

UserProfile   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 112
c 0
b 0
f 0
wmc 7
lcom 1
cbo 2
ccs 21
cts 21
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getId() 0 4 1
A getUser() 0 4 1
A getBirthDate() 0 4 1
A setBirthDate() 0 5 1
A getContacts() 0 4 1
A addContacts() 0 10 1
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Users\Entity;
5
6
use App\Users\Entity\UserProfileContacts;
7
use App\Users\Entity\User;
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Doctrine\ORM\Mapping as ORM;
10
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
11
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
12
use Symfony\Component\Security\Core\User\UserInterface;
13
use JMS\Serializer\Annotation\Exclude;
14
use JMS\Serializer\Annotation\Expose;
15
16
/**
17
 * @ORM\Entity
18
 * @ORM\Table(name="users_profiles")
19
 */
20
class UserProfile
21
{
22
    /**
23
     * @ORM\Id()
24
     * @ORM\GeneratedValue()
25
     * @ORM\Column(type="integer")
26
     */
27
    private $id;
28
29
    /**
30
     * @var $user User
31
     * @ORM\OneToOne(targetEntity="App\Users\Entity\User", inversedBy="profile")
32
     * @ORM\JoinColumn(nullable=false)
33
     */
34
    private $user;
35
36
    /**
37
     * @var $contacts UserProfileContacts[]|ArrayCollection
38
     * @ORM\OneToMany(targetEntity="App\Users\Entity\UserProfileContacts", mappedBy="profile", cascade={"persist", "remove"})
39
     * @ORM\JoinColumn(nullable=true)
40
     */
41
    private $contacts;
42
43
    /**
44
     * @ORM\Column(type="string", length=255, nullable=true)
45
     */
46
    public $first_name;
47
48
    /**
49
     * @ORM\Column(type="string", length=255, nullable=true)
50
     */
51
    public $last_name;
52
53
    /**
54
     * @ORM\Column(type="date", nullable=true)
55
     */
56
    private $birth_date;
57
58
    /**
59
     * @ORM\Column(type="string", length=255, nullable=true)
60
     */
61
    public $about;
62
63
    /**
64
     * @ORM\Column(type="string", length=255, nullable=true)
65
     */
66
    public $public_email;
67
68 31
    public function __construct(User $user)
69
    {
70 31
        $this->user = $user;
71 31
        $this->contacts = new ArrayCollection();
72 31
    }
73
74
    /**
75
     * @return mixed
76
     */
77 1
    public function getId()
78
    {
79 1
        return $this->id;
80
    }
81
82
    /**
83
     * @return User
84
     */
85 1
    public function getUser(): User
86
    {
87 1
        return $this->user;
88
    }
89
90
    /**
91
     * @return mixed
92
     */
93 2
    public function getBirthDate()
94
    {
95 2
        return $this->birth_date;
96
    }
97
98
    /**
99
     * @param \DateTime $birth_date
100
     * @return UserProfile
101
     */
102 1
    public function setBirthDate(\DateTime $birth_date)
103
    {
104 1
        $this->birth_date = $birth_date;
105 1
        return $this;
106
    }
107
108
    /**
109
     * @return UserProfileContacts[]|ArrayCollection
110
     */
111 2
    public function getContacts()
112
    {
113 2
        return $this->contacts;
114
    }
115
116
    /**
117
     * @param $name
118
     * @param $url
119
     * @return $this
120
     */
121 1
    public function addContacts($name, $url)
122
    {
123 1
        $contact = new UserProfileContacts($this);
124 1
        $contact->provider = $name;
125 1
        $contact->url = $url;
126
127 1
        $this->contacts->add($contact);
128
129 1
        return $this;
130
    }
131
}