Identifier::from()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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