FailedToDeserializeTheCollection   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 4
c 1
b 0
f 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A encountered() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Deserializer;
5
6
use RuntimeException;
7
use Throwable;
8
9
/**
10
 * Notifies the client that the collection could not be deserialized.
11
 *
12
 * @author Stratadox
13
 */
14
final class FailedToDeserializeTheCollection extends RuntimeException implements DeserializationFailure
15
{
16
    /**
17
     * Produces a deserialization exception to throw when a "foreign" exception
18
     * was encountered during the collection deserialization process.
19
     *
20
     * Prepends the original exception message with additional information on
21
     * what happened when the problem occurred.
22
     *
23
     * @param Throwable $exception    The original exception that was caught
24
     *                                while deserialization the collection.
25
     * @return DeserializationFailure The deserialization exception to throw in
26
     *                                place of the encountered exception.
27
     */
28
    public static function encountered(Throwable $exception): DeserializationFailure
29
    {
30
        return new FailedToDeserializeTheCollection(
31
            'Failed to deserialize the collection: ' . $exception->getMessage(),
32
            0,
33
            $exception
34
        );
35
    }
36
}
37