ApplicationUserId::__toString()   A
last analyzed

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
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
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 81
    public function __construct($id = null)
20
    {
21 81
        $this->id = (string) (($id) ?  $id : $this->generateId());
22 81
    }
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 33
    public function __toString()
36
    {
37 33
        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