Passed
Push — master ( 76905c...77eacf )
by Dominik
02:23
created

createInvalidObjectType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 3
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Deserialization;
6
7
final class DeserializerRuntimeException extends \RuntimeException
8
{
9
    /**
10
     * @param string $path
11
     * @param string $givenType
12
     * @param string $wishedType
13
     *
14
     * @return self
15
     */
16 1
    public static function createInvalidDataType(string $path, string $givenType, string $wishedType): self
17
    {
18 1
        return new self(
19 1
            sprintf('There is an invalid data type "%s", needed "%s" at path: "%s"', $givenType, $wishedType, $path)
20
        );
21
    }
22
23
    /**
24
     * @param string $contentType
25
     *
26
     * @return self
27
     */
28 1
    public static function createNotParsable(string $contentType): self
29
    {
30 1
        return new self(sprintf('Data is not parsable with content-type: "%s"', $contentType));
31
    }
32
33
    /**
34
     * @param array $paths
35
     *
36
     * @return self
37
     */
38 1
    public static function createNotAllowedAddtionalFields(array $paths): self
39
    {
40 1
        return new self(sprintf('There are additional field(s) at paths: "%s"', implode('", "', $paths)));
41
    }
42
}
43