BooleanSchema   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A nullable() 0 10 2
A __construct() 0 4 1
1
<?php
2
3
namespace JsonSchema\Schema;
4
5
use JsonSchema\Keyword\TypeKeyword;
6
7
class BooleanSchema extends AbstractSchema
8
{
9 22
    public function __construct()
10
    {
11 22
        parent::__construct(
12 22
            new TypeKeyword('boolean')
13
        );
14 22
    }
15
16
    /**
17
     * @return static
18
     */
19 1
    public function nullable(bool $nullable = true): self
20
    {
21 1
        if (!$nullable) {
22 1
            return $this->with(
23 1
                new TypeKeyword('boolean')
24
            );
25
        }
26
27 1
        return $this->with(
28 1
            new TypeKeyword(['boolean', 'null'])
29
        );
30
    }
31
}
32