GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

StateTransitionFailed   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 103
ccs 19
cts 19
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 1
A getContext() 0 4 1
A getInput() 0 4 1
A getNextState() 0 4 1
A getObject() 0 4 1
1
<?php
2
3
declare (strict_types = 1);
4
5
namespace Noodle\Statemachine\Exception;
6
7
use ArrayObject as Context;
8
use Noodle\State\State;
9
use Noodle\Statemachine\Exception;
10
use Noodle\Stateful\Stateful;
11
use Noodle\Transition\Input\Input;
12
13
class StateTransitionFailed extends Exception
14
{
15
    /**
16
     * The default exception message that will be used if none is provided
17
     *
18
     * @var string
19
     */
20
    const MESSAGE = 'Error occurred while executing a state transition';
21
22
    /**
23
     * The context object shared across state transitions
24
     *
25
     * @var Context
26
     */
27
    private $context;
28
29
    /**
30
     * The stateful object
31
     *
32
     * @var Stateful
33
     */
34
    private $object;
35
36
    /**
37
     * The input that triggered the state transition
38
     *
39
     * @var Input
40
     */
41
    private $input;
42
43
    /**
44
     * The state that would have been achived, had the transition succeeded
45
     *
46
     * @var State
47
     */
48
    private $nextState;
49
50
    /**
51
     * Constructor
52
     *
53
     * @param Input $input
54
     * @param Stateful $object
55
     * @param Context $context
56
     * @param State $nextState
57
     * @param \Exception $previous (Optional)
58
     */
59 2
    public function __construct(
60
        Input $input,
61
        Stateful $object,
62
        Context $context,
63
        State $nextState,
64
        \Exception $previous = null
65
    ) {
66 2
        $message = sprintf(
67 2
            'Failed attempting to %s a %s with current state %s',
68 2
            $input->getName(),
69
            get_class($object),
70 2
            $object->getCurrentStateName()
71
        );
72
73 2
        parent::__construct($message, 0, $previous);
74
75 2
        $this->object = $object;
76 2
        $this->context = $context;
77 2
        $this->input = $input;
78 2
        $this->nextState = $nextState;
79 2
    }
80
81
    /**
82
     * Returns the shared context object
83
     *
84
     * @return Context
85
     */
86 1
    public function getContext() : Context
87
    {
88 1
        return $this->context;
89
    }
90
91
    /**
92
     * Returns the input that triggered the state transition
93
     *
94
     * @return Input
95
     */
96 1
    public function getInput() : Input
97
    {
98 1
        return $this->input;
99
    }
100
101 1
    public function getNextState() : State
102
    {
103 1
        return $this->nextState;
104
    }
105
106
    /**
107
     * Returns the stateful object
108
     *
109
     * @return Stateful
110
     */
111 1
    public function getObject() : Stateful
112
    {
113 1
        return $this->object;
114
    }
115
}
116