Test Failed
Push — ft/states ( eebc9c )
by Ben
29:42 queued 08:49
created

StateException   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 6
c 0
b 0
f 0
dl 0
loc 25
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidState() 0 3 1
A invalidTransitionKey() 0 3 1
A invalidTransition() 0 3 1
A invalidTransitionState() 0 3 1
A malformedTransition() 0 3 1
1
<?php
2
3
namespace Thinktomorrow\Chief\States\State;
4
5
class StateException extends \Exception
6
{
7
    public static function invalidState($state, $currentState, $stateMachine)
8
    {
9
        return new self('Transition to state ['.$state.'] is not allowed from state ['.$currentState.'] or state does not exist on '.get_class($stateMachine));
10
    }
11
12
    public static function malformedTransition($transition, $stateMachine)
13
    {
14
        return new self('Transition ['.$transition.'] is malformed on '.get_class($stateMachine).'. It should contain both a [from:array] and [to:string] value.');
15
    }
16
17
    public static function invalidTransitionKey($transition, $stateMachine)
18
    {
19
        return new self('unknown transition ['.$transition.'] on '.get_class($stateMachine));
20
    }
21
22
    public static function invalidTransition($transition, $state, $stateMachine)
23
    {
24
        return new self('Transition ['.$transition.'] cannot be applied from current state ['.$state.'] on '.get_class($stateMachine));
25
    }
26
27
    public static function invalidTransitionState($transition, $state, $stateMachine)
28
    {
29
        return new self('Transition ['.$transition.'] contains a non existing ['.$state.'] on '.get_class($stateMachine));
30
    }
31
}
32