Composition::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 10
cc 3
nc 3
nop 0
crap 3
1
<?php
2
3
namespace Swaggest\JsonSchema\Structure;
4
5
use Swaggest\JsonSchema\Constraint\Properties;
6
use Swaggest\JsonSchema\Constraint\Type;
7
use Swaggest\JsonSchema\Schema;
8
use Swaggest\JsonSchema\SchemaContract;
9
use Swaggest\JsonSchema\Wrapper;
10
11
/**
12
 * @todo think of anyOf, allOf, oneOf
13
 */
14
class Composition extends Schema
15
{
16
    /**
17
     * @param SchemaContract... $schema
18
     * @throws \Swaggest\JsonSchema\Exception
19 2
     */
20
    public function __construct()
21 2
    {
22 2
        $this->type = Type::OBJECT;
23 2
        $properties = new Properties();
24
        $this->properties = $properties;
25 2
26 2
        foreach (func_get_args() as $arg) {
27 2
            if ($arg instanceof Wrapper) {
28
                $properties->__set($arg->objectItemClass, $arg->nested());
29
            }
30 2
        }
31
    }
32
33
}