Completed
Branch master (755019)
by Oliver
04:40
created

WrongEventForStateException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 0
cbo 0
dl 0
loc 41
ccs 10
cts 10
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getEventName() 0 4 1
A getStateName() 0 4 1
1
<?php
2
3
namespace Metabor\Statemachine\Exception;
4
5
class WrongEventForStateException extends \RuntimeException
6
{
7
    /**
8
     * The event that was triggered.
9
     *
10
     * @var string
11
     */
12
    protected $eventName;
13
14
    /**
15
     * The subject's current state.
16
     *
17
     * @var string
18
     */
19
    protected $stateName;
20
21
    /**
22
     * @param string     $stateName
23
     * @param string     $eventName
24
     * @param int        $code
25
     * @param \Exception $previous
26
     */
27 3
    public function __construct($stateName, $eventName, $code = 0, \Exception $previous = null)
28
    {
29 3
        $this->stateName = $stateName;
30 3
        $this->eventName = $eventName;
31
32 3
        $message = 'Current state "' . $stateName . '" doesn\'t have event "' . $eventName . '"';
33 3
        parent::__construct($message, $code, $previous);
34 3
    }
35
36 1
    public function getEventName()
37
    {
38 1
        return $this->eventName;
39
    }
40
41 1
    public function getStateName()
42
    {
43 1
        return $this->stateName;
44
    }
45
}
46