Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
75.00% covered (warning)
75.00%
3 / 4
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
NotificationPropsFactory
80.00% covered (warning)
80.00%
4 / 5
75.00% covered (warning)
75.00%
3 / 4
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
3.33
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 create
75.00% covered (warning)
75.00%
3 / 4
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
0.00% covered (danger)
0.00%
0 / 1
2.50
1<?php
2
3namespace App\Service\Notification\Factory;
4
5use Psr\Container\ContainerInterface;
6use Symfony\Component\DependencyInjection\Attribute\AutowireLocator;
7
8/**
9 * @author Wilhelm Zwertvaegher
10 */
11class 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}

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

NotificationPropsFactory->__construct
13    public function __construct(
14        #[AutowireLocator('app.notification_props_builder', indexAttribute: 'index')]
15        private readonly ContainerInterface $builders,
16    ) {
17    }
NotificationPropsFactory->create
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));
25        $builder = $this->builders->get($source::class);
26
27        return $builder->buildProps($source);
28    }
{main}
3namespace App\Service\Notification\Factory;
4
5use Psr\Container\ContainerInterface;
6use Symfony\Component\DependencyInjection\Attribute\AutowireLocator;
7
8/**
9 * @author Wilhelm Zwertvaegher
10 */
11class 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    }