1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Chubbyphp\Serialization; |
6
|
|
|
|
7
|
|
|
use Psr\Link\LinkInterface; |
8
|
|
|
|
9
|
|
|
final class SerializerLogicException extends \LogicException |
10
|
|
|
{ |
11
|
|
|
public static function createMissingContentType(string $contentType): self |
12
|
|
|
{ |
13
|
|
|
return new self(sprintf('There is no encoder for content-type: "%s"', $contentType)); |
14
|
|
|
} |
15
|
|
|
|
16
|
1 |
|
/** |
17
|
|
|
* @return SerializerLogicException |
18
|
1 |
|
*/ |
19
|
|
|
public static function createWrongDataType(string $path, string $type): self |
20
|
|
|
{ |
21
|
|
|
return new self(sprintf('Wrong data type "%s" at path : "%s"', $type, $path)); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public static function createMissingNormalizer(string $path): self |
25
|
|
|
{ |
26
|
|
|
return new self(sprintf('There is no normalizer at path: "%s"', $path)); |
27
|
1 |
|
} |
28
|
|
|
|
29
|
1 |
|
public static function createMissingMapping(string $class): self |
30
|
|
|
{ |
31
|
|
|
return new self(sprintf('There is no mapping for class: "%s"', $class)); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public static function createMissingMethod(string $class, array $methods): self |
35
|
|
|
{ |
36
|
|
|
return new self( |
37
|
1 |
|
sprintf('There are no accessible method(s) "%s", within class: "%s"', implode('", "', $methods), $class) |
38
|
|
|
); |
39
|
1 |
|
} |
40
|
|
|
|
41
|
|
|
public static function createMissingProperty(string $class, string $property): self |
42
|
|
|
{ |
43
|
|
|
return new self(sprintf('There is no property "%s" within class: "%s"', $property, $class)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public static function createInvalidLinkTypeReturned(string $path, string $type): self |
47
|
1 |
|
{ |
48
|
|
|
return new self( |
49
|
1 |
|
sprintf( |
50
|
|
|
'The link normalizer callback needs to return a %s|null, "%s" given at path: "%s"', |
51
|
|
|
LinkInterface::class, |
52
|
|
|
$type, |
53
|
|
|
$path |
54
|
|
|
) |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|