Person::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types = 1);
2
3
namespace Simplex\Quickstart\Module\Demo\Model;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Hateoas\Configuration\Annotation as Hateoas;
7
use JMS\Serializer\Annotation as Serializer;
8
use Ramsey\Uuid\Uuid;
9
10
/**
11
 * @ORM\Entity(repositoryClass="\Simplex\Quickstart\Module\Demo\Repository\PersonRepository")
12
 *
13
 * @Hateoas\Relation(
14
 *     name = "self",
15
 *     href = @Hateoas\Route(
16
 *         "get_person",
17
 *         parameters = { "id" = "expr(object.getId())" },
18
 *         absolute=true
19
 *     )
20
 * )
21
 */
22
final class Person
23
{
24
    /**
25
     * @var Uuid
26
     *
27
     * @ORM\Id()
28
     * @ORM\Column(type="uuid")
29
     * @ORM\GeneratedValue(strategy="NONE")
30
     *
31
     * @Serializer\Exclude()
32
     */
33
    private $id;
34
35
    /**
36
     * @var string
37
     *
38
     * @ORM\Column(type="string")
39
     */
40
    private $name;
41
42
    /**
43
     * @var string
44
     *
45
     * @ORM\Column(type="string")
46
     */
47
    private $email;
48
49
    /**
50
     * @var string
51
     *
52
     * @ORM\Column(type="string", length=255)
53
     *
54
     * @Serializer\Exclude()
55
     */
56
    private $passwordHash;
57
58 7
    private function __construct()
59
    {
60 7
    }
61
62 7
    public static function register(string $name, string $email, string $password): Person
63
    {
64 7
        $person = new self();
65
66 7
        $person->id = Uuid::uuid4();
67 7
        $person->name = $name;
68 7
        $person->email = $email;
69
        /** @scrutinizer ignore-call */
70 7
        $person->passwordHash = password_hash($password, \PASSWORD_DEFAULT);
71
72 7
        return $person;
73
    }
74
75 3
    public function getId(): Uuid
76
    {
77 3
        return $this->id;
78
    }
79
80 1
    public function getName(): string
81
    {
82 1
        return $this->name;
83
    }
84
85 1
    public function getEmail(): string
86
    {
87 1
        return $this->email;
88
    }
89
90
    public function getPasswordHash(): string
91
    {
92
        return $this->passwordHash;
93
    }
94
}
95