Completed
Pull Request — master (#10)
by
unknown
33:07
created

NonStaticCallableClass   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromAttemptedStaticCall() 0 8 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
    public static function fromAttemptedStaticCall(string $class, string $method) : self
23
    {
24
        return new self(sprintf(
25
            self::ERROR_TEMPLATE,
26
            $class,
27
            $method
28
        ));
29
    }
30
}
31