Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
80.00% |
4 / 5 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ParentAttributeConverter | |
80.00% |
4 / 5 |
|
50.00% |
1 / 2 |
4.13 | |
0.00% |
0 / 1 |
| applyToDomain | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| applyToStorage | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
3.14 | |||
| 1 | <?php |
| 2 | namespace Apie\StorageMetadata\PropertyConverters; |
| 3 | |
| 4 | use Apie\StorageMetadata\Attributes\ParentAttribute; |
| 5 | use Apie\StorageMetadata\Interfaces\PropertyConverterInterface; |
| 6 | use Apie\StorageMetadata\Mediators\DomainToStorageContext; |
| 7 | |
| 8 | class ParentAttributeConverter implements PropertyConverterInterface |
| 9 | { |
| 10 | public function applyToDomain( |
| 11 | DomainToStorageContext $context |
| 12 | ): void { |
| 13 | // no-op |
| 14 | } |
| 15 | |
| 16 | public function applyToStorage( |
| 17 | DomainToStorageContext $context |
| 18 | ): void { |
| 19 | if (!isset($context->parentContext)) { |
| 20 | return; |
| 21 | } |
| 22 | foreach ($context->storageProperty->getAttributes(ParentAttribute::class) as $propertyAttribute) { |
| 23 | $context->setStoragePropertyValue($context->parentContext->storageObject); |
| 24 | } |
| 25 | } |
| 26 | } |