Issues (100)

tests/TestModel/Instance/FlyingAnimal.php (1 issue)

Labels
Severity
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
abstract class FlyingAnimal extends Animal
14
{
15
    public static $flightInstructorChild;
16
    public static $flightPartnerRefsColl;
17
    public static $wingspanAttribute;
18
19
    public function __construct(ModelTypeInstanceContext $instanceContext)
20
    {
21
        parent::__construct($instanceContext);
22
    }
23
24
    public static function registerType(ModelBuilder $modelBuilder): void
25
    {
26
        $typeBuilder = $modelBuilder->defineType(
27
            FlyingAnimal::class,
28
            TestModelConstants::TYPE_NAME_FLYING_ANIMAL
29
        )
30
        ->namespaceUri(TestModelConstants::MODEL_NAMESPACE)
31
        ->extendsType(Animal::class)
0 ignored issues
show
The method extendsType() does not exist on Xml\Type\ModelElementTypeBuilderInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Xml\Type\ModelElementTypeBuilderInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        ->/** @scrutinizer ignore-call */ extendsType(Animal::class)
Loading history...
32
        ->abstractType();
33
34
        self::$wingspanAttribute = $typeBuilder->doubleAttribute(TestModelConstants::ATTRIBUTE_NAME_WINGSPAN)
35
        ->build();
36
37
        $sequence = $typeBuilder->sequence();
38
39
        self::$flightInstructorChild = $sequence->element(FlightInstructor::class)
40
        ->idElementReference(FlyingAnimal::class)
41
        ->build();
42
43
        self::$flightPartnerRefsColl = $sequence->elementCollection(FlightPartnerRef::class)
44
        ->idElementReferenceCollection(FlyingAnimal::class)
45
        ->build();
46
47
        $typeBuilder->build();
48
    }
49
50
    public function getWingspan(): ?float
51
    {
52
        return self::$wingspanAttribute->getValue($this);
53
    }
54
55
    public function setWingspan(float $wingspan): void
56
    {
57
        self::$wingspanAttribute->setValue($this, $wingspan);
58
    }
59
60
    public function getFlightInstructor(): ?FlyingAnimal
61
    {
62
        return self::$flightInstructorChild->getReferenceTargetElement($this);
63
    }
64
65
    public function setFlightInstructor(FlyingAnimal $flightInstructor): void
66
    {
67
        self::$flightInstructorChild->setReferenceTargetElement($this, $flightInstructor);
68
    }
69
70
    public function removeFlightInstructor(): void
71
    {
72
        self::$flightInstructorChild->clearReferenceTargetElement($this);
73
    }
74
75
    public function getFlightPartnerRefs(): array
76
    {
77
        return self::$flightPartnerRefsColl->getReferenceTargetElements($this);
78
    }
79
80
    public function addFlightPartnerRef(FlyingAnimal $flightPartner): void
81
    {
82
        self::$flightPartnerRefsColl->add($this, $flightPartner);
83
    }
84
85
    public function removeFlightPartnerRef(FlyingAnimal $flightPartner): void
86
    {
87
        self::$flightPartnerRefsColl->remove($this, $flightPartner);
88
    }
89
90
    public function clearFlightPartnerRefs(): void
91
    {
92
        self::$flightPartnerRefsColl->clear($this);
93
    }
94
95
    public function getFlightPartnerRefElements(): array
96
    {
97
        return self::$flightPartnerRefsColl->getReferenceSourceCollection()->get($this);
98
    }
99
100
    public function addFlightPartnerRefElement(FlightPartnerRef $ref): void
101
    {
102
        self::$flightPartnerRefsColl->getReferenceSourceCollection()->add($this, $ref);
103
    }
104
105
    public function removeFlightPartnerRefElement(FlightPartnerRef $ref): void
106
    {
107
        self::$flightPartnerRefsColl->getReferenceSourceCollection()->remove($this, $ref);
108
    }
109
110
    public function clearFlightPartnerRefElements(): void
111
    {
112
        self::$flightPartnerRefsColl->getReferenceSourceCollection()->clear($this);
113
    }
114
}
115