Completed
Push — master ( e85a68...b6ead1 )
by Jesse
03:13
created

CouldNotConvertToJson   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A encountered() 0 10 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
    {
21
        return new CouldNotConvertToJson(withMessage(
22
            'Could not convert the `%s` class to json: %s',
23
            theClassOf($theCollection),
24
            $exception->getMessage()
25
        ), 0, $exception);
26
    }
27
}
28