Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
Animal
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
5 / 5
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAnimalName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAnimalName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDiscriminatorMapping
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\IntegrationTests\Apie\TypeDemo\Resources;
3
4use Apie\Core\Entities\PolymorphicEntityInterface;
5use Apie\Core\Other\DiscriminatorConfig;
6use Apie\Core\Other\DiscriminatorMapping;
7use Apie\IntegrationTests\Apie\TypeDemo\Entities\Bird;
8use Apie\IntegrationTests\Apie\TypeDemo\Entities\Fish;
9use Apie\IntegrationTests\Apie\TypeDemo\Entities\Mammal;
10use Apie\IntegrationTests\Apie\TypeDemo\Identifiers\AnimalIdentifier;
11use Apie\TextValueObjects\FirstName;
12
13abstract class Animal implements PolymorphicEntityInterface
14{
15    public function __construct(
16        protected AnimalIdentifier $id,
17        private FirstName $animalName,
18    ) {
19    }
20
21    final public function getId(): AnimalIdentifier
22    {
23        return $this->id;
24    }
25
26    final public function setAnimalName(FirstName $animalName): self
27    {
28        $this->animalName = $animalName;
29        return $this;
30    }
31
32    final public function getAnimalName(): FirstName
33    {
34        return $this->animalName;
35    }
36
37    public static function getDiscriminatorMapping(): DiscriminatorMapping
38    {
39        return new DiscriminatorMapping(
40            'type',
41            new DiscriminatorConfig('mammal', Mammal::class),
42            new DiscriminatorConfig('bird', Bird::class),
43            new DiscriminatorConfig('fish', Fish::class)
44        );
45    }
46}