Animal   A
last analyzed

Complexity

Total Complexity 32

Size/Duplication

Total Lines 220
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 75
c 0
b 0
f 0
dl 0
loc 220
rs 9.84
wmc 32

32 Methods

Rating   Name   Duplication   Size   Complexity  
A isEndangered() 0 3 1
A getId() 0 3 1
A setName() 0 3 1
A removeRelationshipDefinitionRefElement() 0 3 1
A getRelationshipDefinitions() 0 3 1
A removeFriend() 0 3 1
A clearFriends() 0 3 1
A addRelationship() 0 3 1
A setIsEndangered() 0 3 1
A __construct() 0 3 1
A getAge() 0 3 1
A setAge() 0 3 1
A getName() 0 3 1
A addFriend() 0 3 1
A getMother() 0 3 1
A registerType() 0 49 1
A addRelationshipDefinitionRefElement() 0 3 1
A getFatherRef() 0 3 1
A getGender() 0 3 1
A clearRelationshipDefinitions() 0 3 1
A getBestFriends() 0 3 1
A setMother() 0 3 1
A getFather() 0 3 1
A clearRelationshipDefinitionRefElements() 0 3 1
A clearRelationships() 0 3 1
A addRelationshipDefinition() 0 3 1
A setId() 0 3 1
A getRelationshipDefinitionRefs() 0 3 1
A getRelationshipDefinitionRefElements() 0 3 1
A setGender() 0 3 1
A setFather() 0 3 1
A removeRelationship() 0 3 1
1
<?php
2
3
namespace Tests\TestModel\Instance;
4
5
use Xml\ModelBuilder;
6
use Xml\Impl\Instance\ModelElementInstanceImpl;
7
use Tests\TestModel\{
8
    Gender,
9
    TestModelConstants
10
};
11
use Xml\Impl\Instance\ModelTypeInstanceContext;
12
13
abstract class Animal extends ModelElementInstanceImpl
14
{
15
    protected static $idAttr;
16
    protected static $nameAttr;
17
    protected static $fatherRef;
18
    protected static $motherRef;
19
    protected static $isEndangeredAttr;
20
    protected static $genderAttr;
21
    protected static $ageAttr;
22
    protected static $bestFriendsRefCollection;
23
    protected static $relationshipDefinitionsColl;
24
    protected static $relationshipDefinitionRefsColl;
25
26
    public static function registerType(ModelBuilder $modelBuilder): void
27
    {
28
29
        $typeBuilder = $modelBuilder->defineType(Animal::class, TestModelConstants::TYPE_NAME_ANIMAL)
30
            ->namespaceUri(TestModelConstants::MODEL_NAMESPACE)
31
            ->abstractType();
32
33
        self::$idAttr = $typeBuilder->stringAttribute(TestModelConstants::ATTRIBUTE_NAME_ID)
34
            ->idAttribute()
35
            ->build();
36
37
        self::$nameAttr = $typeBuilder->stringAttribute(TestModelConstants::ATTRIBUTE_NAME_NAME)
38
            ->build();
39
40
        self::$fatherRef = $typeBuilder->stringAttribute(TestModelConstants::ATTRIBUTE_NAME_FATHER)
41
            ->qNameAttributeReference(Animal::class)
42
            ->build();
43
44
        self::$motherRef = $typeBuilder->stringAttribute(TestModelConstants::ATTRIBUTE_NAME_MOTHER)
45
            ->idAttributeReference(Animal::class)
46
            ->build();
47
48
        self::$isEndangeredAttr = $typeBuilder->booleanAttribute(TestModelConstants::ATTRIBUTE_NAME_IS_ENDANGERED)
49
            ->defaultValue(false)
50
            ->build();
51
52
        self::$genderAttr = $typeBuilder->enumAttribute(TestModelConstants::ATTRIBUTE_NAME_GENDER, Gender::class)
53
            ->required()
54
            ->build();
55
56
        self::$ageAttr = $typeBuilder->integerAttribute(TestModelConstants::ATTRIBUTE_NAME_AGE)
57
            ->build();
58
59
        self::$bestFriendsRefCollection = $typeBuilder->stringAttribute(
60
            TestModelConstants::ATTRIBUTE_NAME_BEST_FRIEND_REFS
61
        )
62
        ->idAttributeReferenceCollection(Animal::class, AnimalAttributeReferenceCollection::class)
63
        ->build();
64
65
        $sequence = $typeBuilder->sequence();
66
67
        self::$relationshipDefinitionsColl = $sequence->elementCollection(RelationshipDefinition::class)
68
            ->build();
69
70
        self::$relationshipDefinitionRefsColl = $sequence->elementCollection(RelationshipDefinitionRef::class)
71
            ->qNameElementReferenceCollection(RelationshipDefinition::class)
72
            ->build();
73
74
        $typeBuilder->build();
75
    }
76
77
    public function __construct(ModelTypeInstanceContext $instanceContext)
78
    {
79
        parent::__construct($instanceContext);
80
    }
81
82
    public function getId(): ?string
83
    {
84
        return self::$idAttr->getValue($this);
85
    }
86
87
    public function setId(string $id): void
88
    {
89
        self::$idAttr->setValue($this, $id);
90
    }
91
92
    public function getName(): ?string
93
    {
94
        return self::$nameAttr->getValue($this);
95
    }
96
97
    public function setName(string $name): void
98
    {
99
        self::$nameAttr->setValue($this, $name);
100
    }
101
102
    public function getFather(): ?Animal
103
    {
104
        return self::$fatherRef->getReferenceTargetElement($this);
105
    }
106
107
    public function getFatherRef()
108
    {
109
        return self::$fatherRef;
110
    }
111
112
    public function setFather(Animal $father): void
113
    {
114
        self::$fatherRef->setReferenceTargetElement($this, $father);
115
    }
116
117
    public function getMother(): ?Animal
118
    {
119
        return self::$motherRef->getReferenceTargetElement($this);
120
    }
121
122
    public function setMother(Animal $mother): void
123
    {
124
        self::$motherRef->setReferenceTargetElement($this, $mother);
125
    }
126
127
    public function isEndangered(): bool
128
    {
129
        return self::$isEndangeredAttr->getValue($this);
130
    }
131
132
    /**
133
     * @param mixed $isEndangered
134
     */
135
    public function setIsEndangered($isEndangered): void
136
    {
137
        self::$isEndangeredAttr->setValue($this, $isEndangered);
138
    }
139
140
    public function getGender(): ?string
141
    {
142
        return self::$genderAttr->getValue($this);
143
    }
144
145
    public function setGender(string $gender): void
146
    {
147
        self::$genderAttr->setValue($this, $gender);
148
    }
149
150
    public function getAge(): ?int
151
    {
152
        return self::$ageAttr->getValue($this);
153
    }
154
155
    public function setAge(int $age): void
156
    {
157
        self::$ageAttr->setValue($this, $age);
158
    }
159
160
    public function getRelationshipDefinitions(): array
161
    {
162
        return self::$relationshipDefinitionsColl->get($this);
163
    }
164
165
    public function getRelationshipDefinitionRefs(): array
166
    {
167
        return self::$relationshipDefinitionRefsColl->getReferenceTargetElements($this);
168
    }
169
170
    public function getRelationshipDefinitionRefElements(): array
171
    {
172
        return self::$relationshipDefinitionRefsColl->getReferenceSourceCollection()->get($this);
173
    }
174
175
    public function addRelationshipDefinitionRefElement(RelationshipDefinitionRef $rel): void
176
    {
177
        self::$relationshipDefinitionRefsColl->getReferenceSourceCollection()->add($this, $rel);
178
    }
179
180
    public function removeRelationshipDefinitionRefElement(RelationshipDefinitionRef $rel): void
181
    {
182
        self::$relationshipDefinitionRefsColl->getReferenceSourceCollection()->remove($this, $rel);
183
    }
184
185
    public function clearRelationshipDefinitionRefElements(): void
186
    {
187
        self::$relationshipDefinitionRefsColl->getReferenceSourceCollection()->clear($this);
188
    }
189
190
    public function getBestFriends(): array
191
    {
192
        return self::$bestFriendsRefCollection->getReferenceTargetElements($this);
193
    }
194
195
    public function addRelationshipDefinition(RelationshipDefinition $rel): void
196
    {
197
        self::$relationshipDefinitionRefsColl->add($this, $rel);
198
    }
199
200
    public function addRelationship(RelationshipDefinition $rel): void
201
    {
202
        self::$relationshipDefinitionsColl->add($this, $rel);
203
    }
204
205
    public function removeRelationship(RelationshipDefinition $rel): void
206
    {
207
        self::$relationshipDefinitionsColl->remove($this, $rel);
208
    }
209
210
    public function clearRelationships(): void
211
    {
212
        self::$relationshipDefinitionsColl->clear($this);
213
    }
214
215
    public function clearRelationshipDefinitions(): void
216
    {
217
        self::$relationshipDefinitionRefsColl->clear($this);
218
    }
219
220
    public function addFriend(Animal $friend): void
221
    {
222
        self::$bestFriendsRefCollection->add($this, $friend);
223
    }
224
225
    public function removeFriend(Animal $friend): void
226
    {
227
        self::$bestFriendsRefCollection->remove($this, $friend);
228
    }
229
230
    public function clearFriends(): void
231
    {
232
        self::$bestFriendsRefCollection->clear($this);
233
    }
234
}
235