Completed
Push — master ( 86cc7b...35a93c )
by Marco
01:44
created

NonStaticCallableClass::fromAttemptedStaticCall()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dont\Exception;
6
7
use LogicException;
8
9
class NonStaticCallableClass extends LogicException implements ExceptionInterface
10
{
11
    private const ERROR_TEMPLATE = <<<'ERROR'
12
The given class %s is not designed to allow any undefined or inaccessible static methods to be called.
13
14
You tried to call a static method called "%s".
15
16
Perhaps you made a typo in the method name, or tried to call an inaccessible method?
17
ERROR;
18
19
    /**
20
     * @throws TypeError
21
     */
22 3
    public static function fromAttemptedStaticCall(string $class, string $method) : self
23
    {
24 3
        return new self(sprintf(
25 3
            self::ERROR_TEMPLATE,
26 3
            $class,
27 3
            $method
28
        ));
29
    }
30
}
31