AllOfKeyword   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 2
1
<?php
2
3
namespace JsonSchema\Keyword;
4
5
use JsonSchema\Schema\SchemaInterface;
6
use Webmozart\Assert\Assert;
7
8
class AllOfKeyword extends AbstractKeyword
9
{
10
    const NAME = 'allOf';
11
12
    /**
13
     * @param SchemaInterface[]|null $allOfs
14
     */
15 8
    public function __construct(?array $allOfs)
16
    {
17 8
        if (null === $allOfs) {
0 ignored issues
show
introduced by
The condition null === $allOfs is always false.
Loading history...
18 8
            parent::__construct(static::NAME, null);
19
20 8
            return;
21
        }
22
23 8
        Assert::isNonEmptyList($allOfs);
24 8
        Assert::allIsInstanceOf($allOfs, SchemaInterface::class);
25
26 8
        parent::__construct(static::NAME, array_map(
27 8
            function (SchemaInterface $schemaMetadata) {
28 8
                return $schemaMetadata->toJsonSchema();
29 8
            },
30
            $allOfs
31
        ));
32 8
    }
33
}
34