Test Failed
Push — master ( 851737...5a0e08 )
by Dominik
01:50
created

SerializerLogicException::createWrongDataType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization;
6
7
final class SerializerLogicException extends \LogicException
8
{
9
    /**
10
     * @param string $contentType
11
     *
12
     * @return self
13
     */
14
    public static function createMissingContentType(string $contentType): self
15
    {
16
        return new self(sprintf('There is no encoder for content-type: "%s"', $contentType));
17
    }
18
19
    /**
20
     * @param string $path
21
     * @param string $type
22
     * @return SerializerLogicException
23
     */
24
    public static function createWrongDataType(string $path, string $type): self
25
    {
26
        return new self(sprintf('Wrong data type "%s" at path : "%s"', $type, $path));
27
    }
28
29
    /**
30
     * @param string $path
31
     *
32
     * @return self
33
     */
34
    public static function createMissingNormalizer(string $path): self
35
    {
36
        return new self(sprintf('There is no normalizer at path: "%s"', $path));
37
    }
38
39
    /**
40
     * @param string $class
41
     *
42
     * @return self
43
     */
44
    public static function createMissingMapping(string $class): self
45
    {
46
        return new self(sprintf('There is no mapping for class: "%s"', $class));
47
    }
48
49
    /**
50
     * @param string $class
51
     * @param array  $methods
52
     *
53
     * @return self
54
     */
55
    public static function createMissingMethod(string $class, array $methods): self
56
    {
57
        return new self(
58
            sprintf('There are no accessible method(s) "%s", within class: "%s"', implode('", "', $methods), $class)
59
        );
60
    }
61
62
    /**
63
     * @param string $class
64
     * @param string $property
65
     *
66
     * @return self
67
     */
68
    public static function createMissingProperty(string $class, string $property): self
69
    {
70
        return new self(sprintf('There is no property "%s" within class: "%s"', $property, $class));
71
    }
72
}
73