Identifier   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A __construct() 0 3 1
A is() 0 3 1
A id() 0 3 1
A from() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\CardGame;
4
5
abstract class Identifier
6
{
7
    private $id;
8
9
    private function __construct(string $id)
10
    {
11
        $this->id = $id;
12
    }
13
14
    /** @return static */
15
    public static function from($id): self
16
    {
17
        return new static((string) $id);
18
    }
19
20
    public function is(self $that): bool
21
    {
22
        return (string) $this === (string) $that;
23
    }
24
25
    public function id(): string
26
    {
27
        return $this->id;
28
    }
29
30
    public function __toString(): string
31
    {
32
        return $this->id;
33
    }
34
}
35