Person   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Test Coverage

Coverage 88.24%

Importance

Changes 0
Metric Value
dl 0
loc 71
ccs 15
cts 17
cp 0.8824
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getId() 0 3 1
A getName() 0 3 1
A getPasswordHash() 0 3 1
A register() 0 11 1
A getEmail() 0 3 1
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