NumberSchema   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 72
ccs 25
cts 25
cp 1
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A exclusiveMinimum() 0 4 1
A maximum() 0 4 1
A minimum() 0 4 1
A exclusiveMaximum() 0 4 1
A nullable() 0 10 2
A multipleOf() 0 4 1
1
<?php
2
3
namespace JsonSchema\Schema;
4
5
use JsonSchema\Keyword\ExclusiveMaximumKeyword;
6
use JsonSchema\Keyword\ExclusiveMinimumKeyword;
7
use JsonSchema\Keyword\MaximumKeyword;
8
use JsonSchema\Keyword\MinimumKeyword;
9
use JsonSchema\Keyword\MultipleOfKeyword;
10
use JsonSchema\Keyword\TypeKeyword;
11
12
class NumberSchema extends AbstractSchema
13
{
14 27
    public function __construct()
15
    {
16 27
        parent::__construct(
17 27
            new TypeKeyword('number')
18
        );
19 27
    }
20
21
    /**
22
     * @return static
23
     */
24 1
    public function nullable(bool $nullable = true): self
25
    {
26 1
        if (!$nullable) {
27 1
            return $this->with(
28 1
                new TypeKeyword('number')
29
            );
30
        }
31
32 1
        return $this->with(
33 1
            new TypeKeyword(['number', 'null'])
34
        );
35
    }
36
37
    /**
38
     * @return static
39
     */
40 1
    public function minimum(?float $minimum): self
41
    {
42 1
        return $this->with(
43 1
            new MinimumKeyword($minimum)
44
        );
45
    }
46
47
    /**
48
     * @return static
49
     */
50 1
    public function maximum(?float $maximum): self
51
    {
52 1
        return $this->with(
53 1
            new MaximumKeyword($maximum)
54
        );
55
    }
56
57
    /**
58
     * @return static
59
     */
60 1
    public function exclusiveMinimum(?float $exclusiveMinimum): self
61
    {
62 1
        return $this->with(
63 1
            new ExclusiveMinimumKeyword($exclusiveMinimum)
64
        );
65
    }
66
67
    /**
68
     * @return static
69
     */
70 1
    public function exclusiveMaximum(?float $exclusiveMaximum): self
71
    {
72 1
        return $this->with(
73 1
            new ExclusiveMaximumKeyword($exclusiveMaximum)
74
        );
75
    }
76
77
    /**
78
     * @return static
79
     */
80 1
    public function multipleOf(?float $multipleOf): self
81
    {
82 1
        return $this->with(
83 1
            new MultipleOfKeyword($multipleOf)
84
        );
85
    }
86
}
87