Passed
Push — master ( 4da179...4cded1 )
by Yannick
02:33
created

OneToOneTransition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
dl 0
loc 55
ccs 14
cts 16
cp 0.875
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A onRegister() 0 4 1
A getName() 0 3 1
A getDestinationState() 0 3 1
A __construct() 0 8 1
1
<?php
2
3
namespace Star\Component\State\Transitions;
4
5
use Star\Component\State\RegistryBuilder;
6
use Star\Component\State\StateTransition;
7
use Webmozart\Assert\Assert;
8
9
final class OneToOneTransition implements StateTransition
10
{
11
    /**
12
     * @var string
13
     */
14
    private $name;
15
16
    /**
17
     * @var string
18
     */
19
    private $from;
20
21
    /**
22
     * @var string
23
     */
24
    private $to;
25
26
    /**
27
     * @param string $name
28
     * @param string $from
29
     * @param string $to
30
     */
31 48
    public function __construct($name, $from, $to)
32
    {
33 48
        Assert::string($name);
34 48
        Assert::string($from);
35 48
        Assert::string($to);
36 48
        $this->name = $name;
37 48
        $this->from = $from;
38 48
        $this->to = $to;
39 48
    }
40
41
    /**
42
     * @return string
43
     */
44 47
    public function getName()
45
    {
46 47
        return $this->name;
47
    }
48
49
    /**
50
     * @param RegistryBuilder $registry
51
     */
52 47
    public function onRegister(RegistryBuilder $registry)
53
    {
54 47
        $registry->registerStartingState($this->name, $this->from, []);
55 47
        $registry->registerDestinationState($this->name, $this->to, []);
56 47
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getDestinationState()
62
    {
63
        return $this->to;
64
    }
65
}
66