Passed
Push — 1.0.0 ( ce26bf...83ab09 )
by Alex
01:35
created

UUIDV1   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 45.45%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 27
ccs 5
cts 11
cp 0.4545
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 3 1
A getId() 0 3 1
A fromString() 0 3 1
A __construct() 0 3 1
A getHumanReadableId() 0 3 1
1
<?php
2
3
namespace StraTDeS\VO\Single;
4
5
use Ramsey\Uuid\Uuid;
6
use Ramsey\Uuid\UuidInterface;
7
8
class UUIDV1 extends Id
9
{
10
    private UuidInterface $id;
11
12 2
    private function __construct(UuidInterface $id)
13
    {
14 2
        $this->id = $id;
15 2
    }
16
17
    public static function generate(): UUIDV1
18
    {
19
        return new static(Uuid::uuid1());
20
    }
21
22
    public function getId(): UuidInterface
23
    {
24
        return $this->id;
25
    }
26
27 2
    public static function fromString(string $string): UUIDV1
28
    {
29 2
        return new static(Uuid::fromString($string));
30
    }
31
32
    public function getHumanReadableId(): string
33
    {
34
        return $this->id->toString();
35
    }
36
}
37