Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
IsPolymorphicStorage
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 createDomainObject
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\StorageMetadataBuilder\Concerns;
3
4use Apie\Core\Entities\PolymorphicEntityInterface;
5use Apie\Core\Utils\EntityUtils;
6use ReflectionClass;
7
8/**
9 * Added for storing polymorphic entities.
10 *
11 * @see PolymorphicEntityInterface
12 */
13trait 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}