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

WrongEventForStateException::getEventName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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