Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
8 / 8 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
Animal | |
100.00% |
8 / 8 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDiscriminatorMapping | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | namespace Apie\Fixtures\Entities\Polymorphic; |
3 | |
4 | use Apie\Core\Entities\PolymorphicEntityInterface; |
5 | use Apie\Core\Other\DiscriminatorConfig; |
6 | use Apie\Core\Other\DiscriminatorMapping; |
7 | |
8 | abstract class Animal implements PolymorphicEntityInterface |
9 | { |
10 | private AnimalIdentifier $id; |
11 | |
12 | public function __construct(?AnimalIdentifier $id = null) |
13 | { |
14 | $this->id = $id ?? AnimalIdentifier::createRandom(); |
15 | } |
16 | |
17 | public function getId(): AnimalIdentifier |
18 | { |
19 | return $this->id; |
20 | } |
21 | |
22 | final public static function getDiscriminatorMapping(): DiscriminatorMapping |
23 | { |
24 | return new DiscriminatorMapping( |
25 | 'animalType', |
26 | new DiscriminatorConfig('cow', Cow::class), |
27 | new DiscriminatorConfig('elephant', Elephant::class), |
28 | new DiscriminatorConfig('fish', Fish::class) |
29 | ); |
30 | } |
31 | } |