Completed
Pull Request — master (#23)
by John
02:43
created

ComplexType   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 97
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A addChild() 0 5 1
A addParent() 0 6 1
A getParents() 0 4 1
A getChildren() 0 4 1
A getClassName() 0 4 1
A getName() 0 4 1
A getSchema() 0 4 1
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the KleijnWeb\PhpApi\Descriptions package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\PhpApi\Descriptions\Description;
10
11
use KleijnWeb\PhpApi\Descriptions\Description\Schema\ObjectSchema;
12
13
/**
14
 * @author John Kleijn <[email protected]>
15
 */
16
class ComplexType
17
{
18
    /**
19
     * @var string
20
     */
21
    private $name;
22
23
    /**
24
     * @var ObjectSchema
25
     */
26
    private $schema;
27
28
    /**
29
     * @var ComplexType[]
30
     */
31
    private $parents = [];
32
33
    /**
34
     * @var ComplexType[]
35
     */
36
    private $children = [];
37
38
    /**
39
     * @var null|string
40
     */
41
    private $className;
42
43
    public function __construct(string $name, ObjectSchema $schema, string $className)
44
    {
45
        $this->name      = $name;
46
        $this->schema    = $schema;
47
        $this->className = $className;
48
    }
49
50
    /**
51
     * @param ComplexType $child
52
     *
53
     * @return ComplexType
54
     */
55
    public function addChild(ComplexType $child): ComplexType
56
    {
57
        $this->children[] = $child;
58
        return $this;
59
    }
60
61
    /**
62
     * @param ComplexType $parent
63
     *
64
     * @return ComplexType
65
     */
66
    public function addParent(ComplexType $parent): ComplexType
67
    {
68
        $this->parents[] = $parent;
69
        $parent->addChild($this);
70
        return $this;
71
    }
72
73
    /**
74
     * @return ComplexType[]
75
     */
76
    public function getParents(): array
77
    {
78
        return $this->parents;
79
    }
80
81
    /**
82
     * @return ComplexType[]
83
     */
84
    public function getChildren(): array
85
    {
86
        return $this->children;
87
    }
88
89
    /**
90
     * @return null|string
91
     */
92
    public function getClassName()
93
    {
94
        return $this->className;
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function getName(): string
101
    {
102
        return $this->name;
103
    }
104
105
    /**
106
     * @return ObjectSchema
107
     */
108
    public function getSchema(): ObjectSchema
109
    {
110
        return $this->schema;
111
    }
112
}
113