DatabaseSwitchListener::onKernelRequest()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 26
Bugs 0 Features 0
Metric Value
eloc 6
c 26
b 0
f 0
dl 0
loc 9
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
namespace ControleOnline\EventListener;
4
5
use ControleOnline\Service\DatabaseSwitchService;
6
use ControleOnline\Service\DomainService;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Service\DomainService 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...
7
use Symfony\Component\HttpKernel\Event\RequestEvent;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpKernel\Event\RequestEvent 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 Exception;
9
10
class DatabaseSwitchListener
11
{
12
    private $domain;
0 ignored issues
show
introduced by
The private property $domain is not used, and could be removed.
Loading history...
13
    private static $tenancy_params;
14
15
16
    public function __construct(
17
        private DatabaseSwitchService $databaseSwitchService,
18
        private DomainService $domainService
19
    ) {
20
    }
21
22
    public function onKernelRequest(RequestEvent $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

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

22
    public function onKernelRequest(/** @scrutinizer ignore-unused */ RequestEvent $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24
        try {
25
            if (!self::$tenancy_params)
26
                self::$tenancy_params = $this->databaseSwitchService->switchDatabaseByDomain(
0 ignored issues
show
Bug introduced by
Are you sure the assignment to self::tenancy_params is correct as $this->databaseSwitchSer...inService->getDomain()) targeting ControleOnline\Service\D...witchDatabaseByDomain() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
27
                    $this->domainService->getDomain()
28
                );
29
        } catch (Exception $e) {
30
            throw new Exception(sprintf('%s', $e), 1);
31
        }
32
    }
33
}
34