QueryCountClient   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
eloc 13
c 0
b 0
f 0
dl 0
loc 28
ccs 3
cts 7
cp 0.4286
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkQueryCount() 0 13 2
A setQueryCounter() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Liip/FunctionalTestBundle
7
 *
8
 * (c) Lukas Kahwe Smith <[email protected]>
9
 *
10
 * This source file is subject to the MIT license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13
14
namespace Liip\FunctionalTestBundle;
15
16
use Symfony\Bundle\FrameworkBundle\Client;
17
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass;
0 ignored issues
show
Bug introduced by
The type Symfony\Bundle\Framework...r\CompilerDebugDumpPass 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...
18
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
19
20
// Symfony <4 BC
21 5
if (class_exists(CompilerDebugDumpPass::class)) {
22
    class_alias(QueryCountClientSymfony3Trait::class, QueryCountClientTrait::class);
23
}
24
25
// Symfony <4.3.1 BC
26 5
if (!class_exists(KernelBrowser::class)) {
27
    class_alias(Client::class, KernelBrowser::class);
28
}
29
30 5
if (!class_exists(Client::class)) {
31
    class_alias(KernelBrowser::class, Client::class);
32
}
33
34
class QueryCountClient extends KernelBrowser
35
{
36
    /*
37
     * We use trait only because of Client::request signature strict type mismatch between Symfony 3 and 4.
38
     */
39
    use QueryCountClientTrait;
40
41
    /** @var QueryCounter */
42
    private $queryCounter;
43
44 5
    public function setQueryCounter(QueryCounter $queryCounter): void
45
    {
46 5
        $this->queryCounter = $queryCounter;
47 5
    }
48
49
    private function checkQueryCount(): void
50
    {
51
        if ($this->getProfile()) {
52
            $this->queryCounter->checkQueryCount(
53
                $this->getProfile()->getCollector('db')->getQueryCount()
0 ignored issues
show
Bug introduced by
The method getQueryCount() does not exist on Symfony\Component\HttpKe...\DataCollectorInterface. It seems like you code against a sub-type of Symfony\Component\HttpKe...\DataCollectorInterface such as Symfony\Bridge\Doctrine\...r\DoctrineDataCollector. ( Ignorable by Annotation )

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

53
                $this->getProfile()->getCollector('db')->/** @scrutinizer ignore-call */ getQueryCount()
Loading history...
54
            );
55
        } else {
56
            // @codeCoverageIgnoreStart
57
            echo "\n".
58
                'Profiler is disabled, it must be enabled for the '.
59
                'Query Counter. '.
60
                'See https://github.com/liip/LiipFunctionalTestBundle#query-counter'.
61
                "\n";
62
            // @codeCoverageIgnoreEnd
63
        }
64
    }
65
}
66