NotAClass   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A cannotInstantiate() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Instantiator;
5
6
use InvalidArgumentException;
7
use function sprintf;
8
9
/**
10
 * Notifies the client code that the class cannot be instantiated because it is
11
 * an interface.
12
 *
13
 * @author Stratadox
14
 */
15
final class NotAClass extends InvalidArgumentException implements InstantiationFailure
16
{
17
    /**
18
     * Creates a new exception.
19
     *
20
     * @param string $class         The class that turns out to be an interface.
21
     * @return InstantiationFailure The exception to throw.
22
     */
23
    public static function cannotInstantiate(string $class): InstantiationFailure
24
    {
25
        return new self(sprintf(
26
            'Could not create instantiator: %s is an interface.',
27
            $class
28
        ));
29
    }
30
}
31