CouldNotConvertToJson   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A encountered() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stratadox\ImmutableCollection;
6
7
use function get_class as theClassOf;
8
use RuntimeException;
9
use function sprintf as withMessage;
10
use Stratadox\Collection\Collection;
11
use Stratadox\Collection\ConversionFailed;
12
use Throwable;
13
14
final class CouldNotConvertToJson extends RuntimeException implements ConversionFailed
15
{
16
    public static function encountered(
17
        Collection $theCollection,
18
        Throwable $exception
19
    ): ConversionFailed {
20
        return new CouldNotConvertToJson(withMessage(
21
            'Could not convert the `%s` class to json: %s',
22
            theClassOf($theCollection),
23
            $exception->getMessage()
24
        ), 0, $exception);
25
    }
26
}
27