MethodToCall::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
nc 2
nop 2
dl 0
loc 11
ccs 5
cts 5
cp 1
crap 3
rs 10
c 2
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\Tactician\Handler\Mapping;
6
7
use function method_exists;
8
9
final class MethodToCall
10
{
11
    private string $className;
12
13
    private string $methodName;
14
15 4
    public function __construct(string $className, string $methodName)
16
    {
17
        // If the method does not actually exist, we'll also check if __call exists (mainly for
18
        // legacy purposes). That said, we won't rewrite the method name to __call because our
19
        // static analysis checker might still be able to infer data from the original method name.
20 4
        if (! method_exists($className, $methodName) && ! method_exists($className, '__call')) {
21 1
            throw MethodDoesNotExist::on($className, $methodName);
22
        }
23
24 3
        $this->className  = $className;
25 3
        $this->methodName = $methodName;
26 3
    }
27
28 3
    public function getClassName(): string
29
    {
30 3
        return $this->className;
31
    }
32
33 3
    public function getMethodName(): string
34
    {
35 3
        return $this->methodName;
36
    }
37
}
38