PropertiesKeyword::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 2
b 0
f 0
nc 3
nop 1
dl 0
loc 18
ccs 10
cts 10
cp 1
crap 3
rs 9.9666
1
<?php
2
3
namespace JsonSchema\Keyword;
4
5
use JsonSchema\Property\PropertyInterface;
6
use Webmozart\Assert\Assert;
7
8
class PropertiesKeyword extends AbstractKeyword
9
{
10
    const NAME = 'properties';
11
12
    /**
13
     * @param PropertyInterface[]|null $properties
14
     */
15 1
    public function __construct(?array $properties)
16
    {
17 1
        if (null === $properties) {
0 ignored issues
show
introduced by
The condition null === $properties is always false.
Loading history...
18 1
            parent::__construct(static::NAME, null);
19
20 1
            return;
21
        }
22
23 1
        Assert::isNonEmptyList($properties);
24 1
        Assert::allIsInstanceOf($properties, PropertyInterface::class);
25
26 1
        $propertiesValue = [];
27
28 1
        foreach ($properties as $property) {
29 1
            $propertiesValue[$property->getName()] = $property->toJsonSchema();
30
        }
31
32 1
        parent::__construct(static::NAME, (object) $propertiesValue);
33 1
    }
34
}
35