Completed
Branch master (933e97)
by Torsten
04:46
created

UuidId::isEqual()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 5
loc 5
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lej\Component\Domain\Model;
6
7
use Ramsey\Uuid\Uuid;
8
use Ramsey\Uuid\UuidInterface;
9
10 View Code Duplication
class UuidId implements Id
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /**
13
     * @var UuidInterface
14
     */
15
    protected $id;
16
17
    /**
18
     * The constructor.
19
     * @param UuidInterface $id
20
     */
21 5
    public function __construct(UuidInterface $id)
22
    {
23 5
        $this->id = $id;
24 5
    }
25
26
    /**
27
     * Constructs the identifier from it's string representation.
28
     * @param string $id
29
     * @return static|UuidId
30
     */
31 1
    public static function fromString(string $id): UuidId
32
    {
33 1
        return new static(Uuid::fromString($id));
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 3
    public function toString(): string
40
    {
41 3
        return $this->id->toString();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 3
    public function isEqual(ValueObject $object): bool
48
    {
49 3
        return $object instanceof static
50 3
            && $object->toString() === $this->toString();
51
    }
52
}
53