-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerializationException.php
More file actions
37 lines (31 loc) · 1.03 KB
/
SerializationException.php
File metadata and controls
37 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace KaririCode\Serializer\Exception;
/**
* Domain exception for all serialization and deserialization failures.
*
* Uses static factory methods for type-safe construction.
*
* @package KaririCode\Serializer\Exception
* @author Walmir Silva <walmir.silva@kariricode.org>
* @since 3.1.0 ARFA 1.3
*/
final class SerializationException extends \RuntimeException
{
public static function encodingFailed(string $format, string $reason): self
{
return new self("Failed to encode to '{$format}': {$reason}");
}
public static function decodingFailed(string $format, string $reason): self
{
return new self("Failed to decode from '{$format}': {$reason}");
}
public static function unsupportedFormat(string $format): self
{
return new self("No encoder registered for format '{$format}'.");
}
public static function duplicateEncoder(string $format): self
{
return new self("Encoder for format '{$format}' is already registered.");
}
}