Completed
Pull Request — master (#23)
by John
03:12
created

ComplexType::addChild()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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
        return $this;
70
    }
71
72
    /**
73
     * @return ComplexType[]
74
     */
75
    public function getParents(): array
76
    {
77
        return $this->parents;
78
    }
79
80
    /**
81
     * @return ComplexType[]
82
     */
83
    public function getChildren(): array
84
    {
85
        return $this->children;
86
    }
87
88
    /**
89
     * @return null|string
90
     */
91
    public function getClassName()
92
    {
93
        return $this->className;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getName(): string
100
    {
101
        return $this->name;
102
    }
103
104
    /**
105
     * @return ObjectSchema
106
     */
107
    public function getSchema(): ObjectSchema
108
    {
109
        return $this->schema;
110
    }
111
}
112