CannotProduceObjects::encountered()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\TableLoader\Builder;
5
6
use function sprintf as withMessage;
7
use Throwable;
8
use UnexpectedValueException as UnexpectedValue;
9
10
/**
11
 * Notifies the client code that producing an object loader was unsuccessful.
12
 *
13
 * @author Stratadox
14
 */
15
final class CannotProduceObjects extends UnexpectedValue implements CannotMakeTableMapping
16
{
17
    /**
18
     * Produces an exception for when when an exception was encountered while
19
     * trying to assemble the infrastructure that loads the objects.
20
     *
21
     * @param Throwable $exception
22
     * @param string    $label
23
     * @return CannotMakeTableMapping
24
     */
25
    public static function encountered(
26
        Throwable $exception,
27
        string $label
28
    ): CannotMakeTableMapping {
29
        return new CannotProduceObjects(withMessage(
30
            'Cannot produce the `%s` objects: %s',
31
            $label,
32
            $exception->getMessage()
33
        ), 0, $exception);
34
    }
35
}
36