GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 69b831...bd71a5 )
by joseph
20:49 queued 13s
created

UuidFactory::getOrderedTimeUuidFromString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Factories;
4
5
use Exception;
6
use Ramsey\Uuid\Codec\OrderedTimeCodec;
7
use Ramsey\Uuid\UuidInterface;
8
9
class UuidFactory
10
{
11
12
    /**
13
     * @var \Ramsey\Uuid\UuidFactory
14
     */
15
    private $orderedTimeFactory;
16
    /**
17
     * @var \Ramsey\Uuid\UuidFactory
18
     */
19
    private $uuidFactory;
20
21
    public function __construct(\Ramsey\Uuid\UuidFactory $uuidFactory)
22
    {
23
24
        $this->orderedTimeFactory = $this->createOrderedTimeFactory($uuidFactory);
25
        $this->uuidFactory        = $uuidFactory;
26
    }
27
28
    private function createOrderedTimeFactory(\Ramsey\Uuid\UuidFactory $uuidFactory): \Ramsey\Uuid\UuidFactory
29
    {
30
        $this->orderedTimeFactory = clone $uuidFactory;
31
        $codec                    = new OrderedTimeCodec(
32
            $this->orderedTimeFactory->getUuidBuilder()
33
        );
34
        $this->orderedTimeFactory->setCodec($codec);
35
36
        return $this->orderedTimeFactory;
37
    }
38
39
    /**
40
     * Get a UUID interface from an ordered time UUID string
41
     *
42
     * @param string $uuidString
43
     *
44
     * @return UuidInterface
45
     */
46 1
    public function getOrderedTimeUuidFromString(string $uuidString): UuidInterface
47
    {
48 1
        return $this->orderedTimeFactory->fromString($uuidString);
49
    }
50
51
    /**
52
     * This is used to get ordered time UUIDs as used in:
53
     * \EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\UuidFieldTrait
54
     *
55
     * @return UuidInterface
56
     * @throws Exception
57
     */
58 2
    public function getOrderedTimeUuid(): UuidInterface
59
    {
60 2
        return $this->orderedTimeFactory->uuid1();
61
    }
62
63
    /**
64
     * This is used to generate standard UUIDs, as used in
65
     * \EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\NonBinaryUuidFieldTrait
66
     *
67
     * @return UuidInterface
68
     * @throws Exception
69
     */
70 1
    public function getUuid(): UuidInterface
71
    {
72 1
        return $this->uuidFactory->uuid4();
73
    }
74
75
    /**
76
     * @return \Ramsey\Uuid\UuidFactory
77
     */
78
    public function getOrderedTimeFactory(): \Ramsey\Uuid\UuidFactory
79
    {
80
        return $this->orderedTimeFactory;
81
    }
82
83
    /**
84
     * @return \Ramsey\Uuid\UuidFactory
85
     */
86
    public function getUuidFactory(): \Ramsey\Uuid\UuidFactory
87
    {
88
        return $this->uuidFactory;
89
    }
90
}
91