SerializerLogicException   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 45
ccs 8
cts 8
cp 1
rs 10
c 2
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A createMissingProperty() 0 3 1
A createMissingMapping() 0 3 1
A createInvalidLinkTypeReturned() 0 8 1
A createMissingContentType() 0 3 1
A createWrongDataType() 0 3 1
A createMissingMethod() 0 4 1
A createMissingNormalizer() 0 3 1
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