AbstractKeyword   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 47
ccs 14
cts 14
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 1
A supportsNullValue() 0 3 1
A getKey() 0 3 1
A getValue() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JsonSchema\Keyword;
6
7
use Webmozart\Assert\Assert;
8
9
abstract class AbstractKeyword implements KeywordInterface
10
{
11
    private string $key;
12
13
    /**
14
     * @var mixed[]|bool|float|int|object|string|null
15
     */
16
    private $value;
17
18
    private bool $supportsNullValue;
19
20
    /**
21
     * @param mixed[]|bool|float|int|object|string|null $value
22
     */
23 200
    public function __construct(string $key, $value, bool $supportsNullValue = false)
24
    {
25 200
        Assert::stringNotEmpty($key);
26 200
        Assert::nullOrOneOf(\gettype($value), [
27 200
            'array',
28
            'boolean',
29
            'float',
30
            'double',
31
            'real',
32
            'integer',
33
            'object',
34
            'string',
35
            'NULL',
36
        ]);
37
38 200
        $this->key = $key;
39 200
        $this->value = $value;
40 200
        $this->supportsNullValue = $supportsNullValue;
41 200
    }
42
43 200
    public function getKey(): string
44
    {
45 200
        return $this->key;
46
    }
47
48 200
    public function getValue()
49
    {
50 200
        return $this->value;
51
    }
52
53 200
    public function supportsNullValue(): bool
54
    {
55 200
        return $this->supportsNullValue;
56
    }
57
}
58