Completed
Push — master ( f80030...418223 )
by Alexandru
06:28
created

Uuid4Generator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 17
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A generate() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Arki\RequestId library.
5
 *
6
 * (c) Alexandru Furculita <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.md.
10
 */
11
12
namespace Arki\RequestId\Generators;
13
14
use Ramsey\Uuid\UuidFactory;
15
use Ramsey\Uuid\UuidFactoryInterface;
16
17
final class Uuid4Generator implements RequestIdGenerator
18
{
19
    private $factory;
20
21
    public function __construct(UuidFactoryInterface $factory = null)
22
    {
23
        $this->factory = $factory ?: new UuidFactory();
24
    }
25
26
    /**
27
     * @return string
28
     */
29
    public function generate()
30
    {
31
        return $this->factory->uuid4()->toString();
32
    }
33
}
34