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

UuidId   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 43
loc 43
c 0
b 0
f 0
wmc 5
lcom 1
cbo 2
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A fromString() 4 4 1
A toString() 4 4 1
A isEqual() 5 5 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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