ElseKeyword::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace JsonSchema\Keyword;
4
5
use JsonSchema\Schema\SchemaInterface;
6
7
class ElseKeyword extends AbstractKeyword
8
{
9
    const NAME = 'else';
10
11 8
    public function __construct(?SchemaInterface $else)
12
    {
13 8
        if (null === $else) {
14 8
            parent::__construct(static::NAME, null);
15
16 8
            return;
17
        }
18
19 8
        parent::__construct(static::NAME, $else->toJsonSchema());
20 8
    }
21
}
22