Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
80.00% |
4 / 5 |
|
75.00% |
3 / 4 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| NotificationPropsFactory | |
80.00% |
4 / 5 |
|
75.00% |
3 / 4 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
3.33 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| create | |
75.00% |
3 / 4 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
0.00% |
0 / 1 |
2.50 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Service\Notification\Factory; |
| 4 | |
| 5 | use Psr\Container\ContainerInterface; |
| 6 | use Symfony\Component\DependencyInjection\Attribute\AutowireLocator; |
| 7 | |
| 8 | /** |
| 9 | * @author Wilhelm Zwertvaegher |
| 10 | */ |
| 11 | class NotificationPropsFactory implements NotificationPropsFactoryInterface |
| 12 | { |
| 13 | public function __construct( |
| 14 | #[AutowireLocator('app.notification_props_builder', indexAttribute: 'index')] |
| 15 | private readonly ContainerInterface $builders, |
| 16 | ) { |
| 17 | } |
| 18 | |
| 19 | public function create(object $source): NotificationProps |
| 20 | { |
| 21 | if (!$this->builders->has($source::class)) { |
| 22 | throw new \InvalidArgumentException(sprintf('No builder found for %s', $source::class)); |
| 23 | } |
| 24 | |
| 25 | $builder = $this->builders->get($source::class); |
| 26 | |
| 27 | return $builder->buildProps($source); |
| 28 | } |
| 29 | } |