Passed
Push — master ( 70acbf...5b5bb9 )
by Luiz Kim
29:52 queued 27:33
created

GetThemeColorsAction::getDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 18
rs 9.9
cc 1
nc 1
nop 1
1
<?php
2
3
namespace ControleOnline\Controller;
4
5
use ControleOnline\Entity\PeopleDomain;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\PeopleDomain was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use ControleOnline\Service\DomainService;
7
use Symfony\Component\HttpFoundation\Request;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Component\HttpFoundation\Response;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Response was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Doctrine\ORM\EntityManagerInterface;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\EntityManagerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
class GetThemeColorsAction
12
{
13
14
    public function __construct(
15
        private EntityManagerInterface $manager,
16
        private DomainService $domainService
17
    ) {
18
    }
19
20
    public function __invoke(Request $request)
21
    {
22
        $domain = $this->domainService->getDomain($request);
0 ignored issues
show
Unused Code introduced by
The call to ControleOnline\Service\DomainService::getDomain() has too many arguments starting with $request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        /** @scrutinizer ignore-call */ 
23
        $domain = $this->domainService->getDomain($request);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
23
        $peopleDomain = $this->manager->getRepository(PeopleDomain::class)->findOneBy(['domain' => $domain]);
24
25
        if (!$peopleDomain) {
26
            return new Response('', Response::HTTP_NOT_FOUND);
27
        }
28
29
        $theme = $peopleDomain->getTheme();
30
        $css = ':root{' . PHP_EOL;
31
        foreach ($theme->getColors(true) as $index => $color) {
32
            $css .= '    --q-' . $index . ': ' . $color . ';' . PHP_EOL;
33
            $css .= '    --'   . $index . ': ' . $color . ';' . PHP_EOL;
34
        }
35
        $css .= '}';
36
        return new Response($css, Response::HTTP_OK, [
37
            'Content-Type' => 'text/css',
38
        ]);
39
    }
40
}
41