Completed
Push — master ( 5b2a97...a8ece2 )
by Ross
01:41
created

MethodDoesNotExist::getMethodName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\Tactician\Handler\Mapping;
6
7
use BadMethodCallException;
8
use League\Tactician\Exception;
9
10
/**
11
 * Thrown when a specific handler object can not be used on a command object.
12
 *
13
 * The most common reason is the receiving method is missing or incorrectly
14
 * named.
15
 */
16
final class MethodDoesNotExist extends BadMethodCallException implements Exception
17
{
18
    private string $className;
19
20
    private string $methodName;
21
22 3
    public static function on(string $className, string $methodName): self
23
    {
24 3
        return new self(
25 3
            'The handler method ' . $className . '::' . $methodName . ' does not exist. Please check your Tactician ' .
26 3
            'mapping configuration or check verify that ' . $methodName . ' is actually declared in . ' . $className,
27
            $className,
28
            $methodName
29
        );
30
    }
31
32 1
    public function getClassName(): string
33
    {
34 1
        return $this->className;
35
    }
36
37 1
    public function getMethodName(): string
38
    {
39 1
        return $this->methodName;
40
    }
41
42 3
    private function __construct(string $message, string $className, string $methodName)
43
    {
44 3
        parent::__construct($message);
45 3
        $this->className  = $className;
46 3
        $this->methodName = $methodName;
47 3
    }
48
}
49