| Total Complexity | 7 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class CreatePolymorphic implements Creator |
||
| 13 | { |
||
| 14 | /** @var Creator[] */ |
||
| 15 | private $mapping; |
||
| 16 | /** @var string */ |
||
| 17 | private $discriminator; |
||
| 18 | /** @var Creator */ |
||
| 19 | private $defaultCreator; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * CreatePolymorphic constructor. |
||
| 23 | * |
||
| 24 | * @param Creator[] $mapping Key is defining the class, value is the creator for this class |
||
| 25 | * @param string $discriminator The name of the field to look for when deciding which class to create |
||
| 26 | * @param Creator $defaultCreator The default creator to use when nothing is found in the mapping |
||
| 27 | */ |
||
| 28 | 9 | public function __construct(array $mapping, $discriminator, Creator $defaultCreator) |
|
| 33 | 9 | } |
|
| 34 | |||
| 35 | /** |
||
| 36 | * Creates a new instance |
||
| 37 | * |
||
| 38 | * @param mixed $data |
||
| 39 | * |
||
| 40 | * @return mixed |
||
| 41 | */ |
||
| 42 | 9 | public function create($data = null) |
|
| 63 |