Completed
Push — refactor-entity-validators ( 9b4b77...c6627d )
by Stefano
13:07 queued 10:18
created

AbstractEntity   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 80%

Importance

Changes 5
Bugs 0 Features 2
Metric Value
wmc 4
c 5
b 0
f 2
lcom 0
cbo 3
dl 0
loc 20
ccs 4
cts 5
cp 0.8
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 4
1
<?php
2
/**
3
 * @author Stefano Torresi (http://stefanotorresi.it)
4
 * @license See the file LICENSE.txt for copying permission.
5
 * ************************************************
6
 */
7
8
namespace Thorr\Persistence\Entity;
9
10
use Ramsey\Uuid\Uuid;
11
12
abstract class AbstractEntity implements UuidProviderInterface
13
{
14
    use UuidProviderTrait;
15
16
    /**
17
     * @param Uuid|string $uuid
18
     */
19 3
    public function __construct($uuid = null)
20
    {
21 3
        if ($uuid !== null && ! $uuid instanceof Uuid) {
22
            $uuid = Uuid::fromString($uuid);
23
        }
24
25 3
        if ($uuid === null) {
26
            $uuid = Uuid::uuid4();
27
        }
28
29
        $this->uuid = $uuid->toString();
30 2
    }
31
}
32