PropertiesKeyword   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 3
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