Passed
Push — master ( 89c1c1...48858c )
by Jesse
07:23
created

NoConcreteClass::cannotInstantiate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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
 * abstract.
12
 *
13
 * @author Stratadox
14
 */
15
final class NoConcreteClass extends InvalidArgumentException implements InstantiationFailure
16
{
17
    /**
18
     * Creates a new exception.
19
     *
20
     * @param string $class    The class that turns out to be abstract.
21
     * @return NoConcreteClass The exception to throw.
22
     */
23
    public static function cannotInstantiate(string $class): InstantiationFailure
24
    {
25
        return new self(sprintf(
26
            'Could not create instantiator: Class %s is abstract.',
27
            $class
28
        ));
29
    }
30
}
31