Animals   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 61
rs 10
wmc 7

14 Methods

Rating   Name   Duplication   Size   Complexity  
addAnimal() 0 3 ?
getDescription() 0 3 ?
A hp$0 ➔ setDescription() 0 3 1
setDescription() 0 3 ?
A hp$0 ➔ registerType() 0 26 1
A hp$0 ➔ getDescription() 0 3 1
A hp$0 ➔ getAnimals() 0 3 1
A hp$0 ➔ newInstance() 0 3 1
A __construct() 0 3 1
A hp$0 ➔ addAnimal() 0 3 1
registerType() 0 26 ?
getAnimals() 0 3 ?
removeAnimal() 0 3 ?
A hp$0 ➔ removeAnimal() 0 3 1
1
<?php
2
3
namespace Tests\TestModel\Instance;
4
5
use Xml\ModelBuilder;
6
use Xml\Impl\Instance\{
7
    ModelElementInstanceImpl,
8
    ModelTypeInstanceContext
9
};
10
use Xml\Type\ModelTypeInstanceProviderInterface;
11
use Tests\TestModel\TestModelConstants;
12
13
class Animals extends ModelElementInstanceImpl
14
{
15
    protected static $descriptionChild;
16
    protected static $animalColl;
17
18
    public function __construct(ModelTypeInstanceContext $instanceContext)
19
    {
20
        parent::__construct($instanceContext);
21
    }
22
23
    public static function registerType(ModelBuilder $modelBuilder): void
24
    {
25
        $typeBuilder = $modelBuilder->defineType(
26
            Animals::class,
27
            TestModelConstants::ELEMENT_NAME_ANIMALS
28
        )
29
        ->namespaceUri(TestModelConstants::MODEL_NAMESPACE)
30
        ->instanceProvider(
31
            new class implements ModelTypeInstanceProviderInterface
32
            {
33
                public function newInstance(ModelTypeInstanceContext $instanceContext): Animals
34
                {
35
                    return new Animals($instanceContext);
36
                }
37
            }
38
        );
39
40
        $sequence = $typeBuilder->sequence();
41
42
        self::$descriptionChild = $sequence->element(Description::class)
43
        ->build();
44
45
        self::$animalColl = $sequence->elementCollection(Animal::class)
46
        ->build();
47
48
        $typeBuilder->build();
49
    }
50
51
    public function getDescription(): Description
52
    {
53
        return self::$descriptionChild->getChild($this);
54
    }
55
56
    public function setDescription(Description $description): void
57
    {
58
        self::$descriptionChild->setChild($this, $description);
59
    }
60
61
    public function getAnimals(): array
62
    {
63
        return self::$animalColl->get($this);
64
    }
65
66
    public function addAnimal(Animal $animal): void
67
    {
68
        self::$animalColl->add($this, $animal);
69
    }
70
71
    public function removeAnimal(Animal $animal): void
72
    {
73
        self::$animalColl->remove($this, $animal);
74
    }
75
}
76