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

OneToOneTransition::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 3
dl 0
loc 8
ccs 7
cts 7
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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