| Conditions | 2 |
| Paths | 2 |
| Total Lines | 10 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public function extract(string $className, array $payload): string |
||
| 17 | 20 | { |
|
| 18 | if ($discriminatorMap = ClassHelper::getAttribute($className, DiscriminatorMap::class)) { |
||
| 19 | 20 | $property = $discriminatorMap->getTypeProperty(); |
|
| 20 | 4 | $mapping = $discriminatorMap->getMapping(); |
|
| 21 | 4 | $parameter = $payload[$property] ?? throw ClassExtractorException::fromDiscriminatorMapWhenParameterIsNull($discriminatorMap); |
|
| 22 | 4 | $className = $mapping[$parameter] ?? throw ClassExtractorException::fromDiscriminatorMapWhenParameterInvalid($discriminatorMap); |
|
| 23 | 3 | } |
|
| 24 | |||
| 25 | return $className; |
||
| 26 | 18 | } |
|
| 28 |