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

Uuid3Generator::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 3
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 View Code Duplication
final class Uuid3Generator implements RequestIdGenerator
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...
18
{
19
    private $ns;
20
21
    private $name;
22
23
    private $factory;
24
25
    /**
26
     * @param UuidFactoryInterface $factory
27
     * @param string               $ns
28
     * @param string               $name
29
     */
30
    public function __construct($ns, $name, UuidFactoryInterface $factory = null)
31
    {
32
        $this->factory = $factory ?: new UuidFactory();
33
        $this->ns = $ns;
34
        $this->name = $name;
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function generate()
41
    {
42
        return $this->factory->uuid3($this->ns, $this->name)->toString();
43
    }
44
}
45