State   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 73.32%

Importance

Changes 0
Metric Value
wmc 6
eloc 15
dl 0
loc 40
ccs 11
cts 15
cp 0.7332
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A normalTyped() 0 3 1
A metadata() 0 3 1
A finalTyped() 0 3 1
A name() 0 3 1
A __construct() 0 5 1
A initialTyped() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dflydev\FiniteStateMachine\State;
6
7
class State
8
{
9
    const INITIAL = 'initial';
10
    const NORMAL = 'normal';
11
    const FINAL = 'final';
12
13
    private string $type;
14
    private string $name;
15
    private array $metadata;
16
17 21
    private function __construct(string $type, string $name, array $metadata = [])
18
    {
19 21
        $this->type = $type;
20 21
        $this->name = $name;
21 21
        $this->metadata = $metadata;
22 21
    }
23
24 21
    public function name(): string
25
    {
26 21
        return $this->name;
27
    }
28
29 6
    public function metadata(): array
30
    {
31 6
        return $this->metadata;
32
    }
33
34
    public static function initialTyped(string $name, array $metadata): self
35
    {
36
        return new static(static::INITIAL, $name, $metadata);
37
    }
38
39 21
    public static function normalTyped(string $name, array $metadata): self
40
    {
41 21
        return new static(static::NORMAL, $name, $metadata);
42
    }
43
44
    public static function finalTyped(string $name, array $metadata): self
45
    {
46
        return new static(static::FINAL, $name, $metadata);
47
    }
48
}
49