PlayerId   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 47
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A equals() 0 4 1
A __toString() 0 4 1
A create() 0 8 2
1
<?php
2
3
namespace MiniGame\Entity;
4
5
use Rhumsaa\Uuid\Uuid;
6
7
class PlayerId
8
{
9
    /**
10
     * @var string
11
     */
12
    private $id;
13
14
    /**
15
     * Constructor
16
     */
17 15
    public function __construct()
18
    {
19 15
    }
20
21
    /**
22
     * @param  PlayerId $id
23
     * @return bool
24
     */
25 3
    public function equals(PlayerId $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 PlayerId
44
     */
45 15
    public static function create($id = null)
46
    {
47 15
        $obj = new self();
48
49 15
        $obj->id = ($id) ? (string) $id : Uuid::uuid4()->toString();
50
51 15
        return $obj;
52
    }
53
}
54