Completed
Push — master ( ad1ec6...dc2720 )
by Rémi
03:15
created

ApplicationUserId::generateId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace MessageApp\User;
4
5
use Rhumsaa\Uuid\Uuid;
6
7
class ApplicationUserId
8
{
9
    /**
10
     * @var string
11
     */
12
    private $id;
13
14
    /**
15
     * Constructor
16
     *
17
     * @param string $id
18
     */
19 6
    public function __construct($id = null)
20
    {
21 6
        $this->id = (string) (($id) ?  $id : $this->generateId());
22 6
    }
23
24
    /**
25
     * @return string
26
     */
27 6
    public function getId()
28
    {
29 6
        return $this->id;
30
    }
31
32
    /**
33
     * @return string
34
     */
35 6
    public function __toString()
36
    {
37 6
        return $this->id;
38
    }
39
40
    /**
41
     * @return string
42
     */
43 3
    protected function generateId()
44
    {
45 3
        return (string) Uuid::uuid4();
46
    }
47
}
48