Completed
Push — master ( c9da35...449f81 )
by Jesse
02:32
created

NoFactoryFound::forData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Proxy;
4
5
use function json_encode;
6
use LogicException;
7
use function sprintf;
8
9
/**
10
 * NoFactoryFound. Exception thrown when none of the proxy factory choices are
11
 * applicable to the known data.
12
 *
13
 * @author Stratadox
14
 */
15
final class NoFactoryFound extends LogicException implements ProxyProductionFailed
16
{
17
    /**
18
     * Indicates that none of the factories are acceptable given the input data.
19
     *
20
     * @param array $knownData The data that was given.
21
     * @return NoFactoryFound  The exception to throw.
22
     */
23
    public static function forData(array $knownData): self
24
    {
25
        return new self(sprintf(
26
            'None of the proxy factories is configured to load the data: %s',
27
            json_encode($knownData)
28
        ));
29
    }
30
}
31