Client::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Domain\Entities;
4
5
use App\Domain\Events\Client\ClientRegistered;
6
use Doctrine\ORM\Mapping AS ORM;
7
use App\Domain\ValueObjects\Email;
8
use Ramsey\Uuid\UuidInterface;
9
10
/**
11
 * @ORM\Entity()
12
 */
13
final class Client extends EntityWithEvents
14
{
15
    /**
16
     * @var Email
17
     * @ORM\Embedded(class = "App\Domain\ValueObjects\Email", columnPrefix = false)
18
     */
19
    private $email;
20
21
    protected function __construct(UuidInterface $id, Email $email)
22
    {
23
        parent::__construct($id);
24
25
        $this->email = $email;
26
    }
27
28
    public static function register(UuidInterface $id, Email $email): Client
29
    {
30
        $client = new Client($id, $email);
31
        $client->record(new ClientRegistered($client->getId()));
32
33
        return $client;
34
    }
35
}