InvalidCommandException::getInvalidCommand()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace League\Tactician\Exception;
4
5
use RuntimeException;
6
7
/**
8
 * Thrown when the command bus is given an non-object to use as a command.
9
 */
10
class InvalidCommandException extends RuntimeException implements Exception
11
{
12
    /**
13
     * @var mixed
14
     */
15
    private $invalidCommand;
16
17
    /**
18
     * @param mixed $invalidCommand
19
     *
20
     * @return static
21
     */
22 2
    public static function forUnknownValue($invalidCommand)
23
    {
24 2
        $exception = new static(
25 2
            'Commands must be an object but the value given was of type: ' . gettype($invalidCommand)
26
        );
27 2
        $exception->invalidCommand = $invalidCommand;
28
29 2
        return $exception;
30
    }
31
32
    /**
33
     * @return mixed
34
     */
35 1
    public function getInvalidCommand()
36
    {
37 1
        return $this->invalidCommand;
38
    }
39
}
40