MiniGameId::__construct()   A
last analyzed

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
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace MiniGame\Entity;
4
5
use Rhumsaa\Uuid\Uuid;
6
7
class MiniGameId
8
{
9
    /**
10
     * @var string
11
     */
12
    private $id;
13
14
    /**
15
     * Constructor
16
     */
17 9
    public function __construct()
18
    {
19 9
    }
20
21
    /**
22
     * @param  MiniGameId $id
23
     * @return bool
24
     */
25 3
    public function equals(MiniGameId $id)
26
    {
27 3
        return $this->id === $id->id;
28
    }
29
30
    /**
31
     * @return string
32
     */
33 6
    public function __toString()
34
    {
35 6
        return (string) $this->id;
36
    }
37
38
    /**
39
     * Static constructor.
40
     *
41
     * @param  string $id
42
     *
43
     * @return MiniGameId
44
     */
45 9
    public static function create($id = null)
46
    {
47 9
        $obj = new self();
48
49 9
        $obj->id = ($id) ? (string) $id : Uuid::uuid4()->toString();
50
51 9
        return $obj;
52
    }
53
}
54