Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| IsPolymorphicStorage | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| createDomainObject | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\StorageMetadataBuilder\Concerns; |
| 3 | |
| 4 | use Apie\Core\Entities\PolymorphicEntityInterface; |
| 5 | use Apie\Core\Utils\EntityUtils; |
| 6 | use ReflectionClass; |
| 7 | |
| 8 | /** |
| 9 | * Added for storing polymorphic entities. |
| 10 | * |
| 11 | * @see PolymorphicEntityInterface |
| 12 | */ |
| 13 | trait IsPolymorphicStorage |
| 14 | { |
| 15 | public function createDomainObject(ReflectionClass $class): object |
| 16 | { |
| 17 | $class = EntityUtils::findClass($this->discriminatorMapping, $class); |
| 18 | assert(null !== $class); |
| 19 | return $class->newInstanceWithoutConstructor(); |
| 20 | } |
| 21 | } |