Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
GenerateNick
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 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
 __invoke
100.00% covered (success)
100.00%
7 / 7
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
1<?php
2
3namespace App\Application\UseCase;
4
5use App\Dto\Command\GenerateNickCommand;
6use App\Dto\Result\GeneratedNickData;
7use App\Service\Data\NickServiceInterface;
8use App\Service\Data\QualifierServiceInterface;
9use App\Service\Data\SubjectServiceInterface;
10use App\Service\Generator\NickGeneratorServiceInterface;
11use Doctrine\ORM\EntityManagerInterface;
12
13/**
14 * @author Wilhelm Zwertvaegher
15 */
16readonly class GenerateNick implements GenerateNickInterface
17{
18    public function __construct(
19        private NickGeneratorServiceInterface $nickGeneratorService,
20        private NickServiceInterface $nickService,
21        private SubjectServiceInterface $subjectService,
22        private QualifierServiceInterface $qualifierService,
23        private EntityManagerInterface $entityManager,
24    ) {
25    }
26
27    public function __invoke(GenerateNickCommand $generateNickCommand): GeneratedNickData
28    {
29        $nickGenerationResult = $this->nickGeneratorService->generateNick($generateNickCommand);
30
31        $nick = $nickGenerationResult->getNick();
32
33        // increment usages count
34        $this->nickService->incrementUsageCount($nick);
35        $this->subjectService->incrementUsageCount($nick->getSubject());
36        $this->qualifierService->incrementUsageCount($nick->getQualifier());
37
38        $this->entityManager->flush();
39
40        return $nickGenerationResult;
41    }
42}

Paths

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

GenerateNick->__construct
18    public function __construct(
19        private NickGeneratorServiceInterface $nickGeneratorService,
20        private NickServiceInterface $nickService,
21        private SubjectServiceInterface $subjectService,
22        private QualifierServiceInterface $qualifierService,
23        private EntityManagerInterface $entityManager,
24    ) {
25    }
GenerateNick->__invoke
27    public function __invoke(GenerateNickCommand $generateNickCommand): GeneratedNickData
28    {
29        $nickGenerationResult = $this->nickGeneratorService->generateNick($generateNickCommand);
30
31        $nick = $nickGenerationResult->getNick();
32
33        // increment usages count
34        $this->nickService->incrementUsageCount($nick);
35        $this->subjectService->incrementUsageCount($nick->getSubject());
36        $this->qualifierService->incrementUsageCount($nick->getQualifier());
37
38        $this->entityManager->flush();
39
40        return $nickGenerationResult;
41    }
{main}
3namespace App\Application\UseCase;
4
5use App\Dto\Command\GenerateNickCommand;
6use App\Dto\Result\GeneratedNickData;
7use App\Service\Data\NickServiceInterface;
8use App\Service\Data\QualifierServiceInterface;
9use App\Service\Data\SubjectServiceInterface;
10use App\Service\Generator\NickGeneratorServiceInterface;
11use Doctrine\ORM\EntityManagerInterface;
12
13/**
14 * @author Wilhelm Zwertvaegher
15 */
16readonly class GenerateNick implements GenerateNickInterface
17{
18    public function __construct(
19        private NickGeneratorServiceInterface $nickGeneratorService,
20        private NickServiceInterface $nickService,
21        private SubjectServiceInterface $subjectService,
22        private QualifierServiceInterface $qualifierService,
23        private EntityManagerInterface $entityManager,
24    ) {
25    }
26
27    public function __invoke(GenerateNickCommand $generateNickCommand): GeneratedNickData
28    {
29        $nickGenerationResult = $this->nickGeneratorService->generateNick($generateNickCommand);
30
31        $nick = $nickGenerationResult->getNick();
32
33        // increment usages count
34        $this->nickService->incrementUsageCount($nick);
35        $this->subjectService->incrementUsageCount($nick->getSubject());
36        $this->qualifierService->incrementUsageCount($nick->getQualifier());
37
38        $this->entityManager->flush();
39
40        return $nickGenerationResult;
41    }