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

MethodDoesNotExist   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 31
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethodName() 0 3 1
A getClassName() 0 3 1
A on() 0 7 1
A __construct() 0 5 1
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