NoSuchClass::encountered()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
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 ReflectionException;
8
use function sprintf;
9
10
/**
11
 * Notifies the client code that the class could not be found.
12
 *
13
 * @author Stratadox
14
 */
15
final class NoSuchClass extends InvalidArgumentException implements InstantiationFailure
16
{
17
    /**
18
     * Creates a new exception.
19
     *
20
     * @param ReflectionException $exception The exception that was encountered.
21
     * @return InstantiationFailure          The new exception to throw.
22
     */
23
    public static function encountered(ReflectionException $exception): InstantiationFailure
24
    {
25
        return new self(sprintf(
26
            'Could not create instantiator: %s.',
27
            $exception->getMessage()
28
        ), 0, $exception);
29
    }
30
}
31