Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#696)
by Vincent
06:39
created

ProfilerController::__invoke()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 35
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 35
ccs 22
cts 22
cp 1
rs 8.9297
cc 6
nc 4
nop 2
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Controller;
6
7
use GraphQL\Utils\SchemaPrinter;
8
use Overblog\GraphQLBundle\Request\Executor as RequestExecutor;
9
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\HttpFoundation\Response;
12
use Symfony\Component\HttpKernel\Profiler\Profiler;
13
use Symfony\Component\Routing\RouterInterface;
14
use Twig\Environment;
15
16
class ProfilerController
17
{
18
    private ?Profiler $profiler;
19
    private ?Environment $twig;
20
    private string $endpointUrl;
21
    private RequestExecutor $requestExecutor;
22
    private ?string $queryMatch;
23
24 3
    public function __construct(?Profiler $profiler, ?Environment $twig, RouterInterface $router, RequestExecutor $requestExecutor, ?string $queryMatch)
25
    {
26 3
        $this->profiler = $profiler;
27 3
        $this->twig = $twig;
28 3
        $this->endpointUrl = $router->generate('overblog_graphql_endpoint');
29 3
        $this->requestExecutor = $requestExecutor;
30 3
        $this->queryMatch = $queryMatch;
31 3
    }
32
33
    /**
34
     * @throws ServiceNotFoundException
35
     */
36 3
    public function __invoke(Request $request, string $token): Response
37
    {
38 3
        if (null === $this->profiler) {
39 1
            throw new ServiceNotFoundException('The profiler must be enabled.');
40
        }
41
42 2
        if (null === $this->twig) {
43 1
            throw new ServiceNotFoundException('The GraphQL Profiler require twig');
44
        }
45
46 1
        $this->profiler->disable();
47
48 1
        $profile = $this->profiler->loadProfile($token);
49
50
        $tokens = \array_map(function ($tokenData) {
51 1
            $profile = $this->profiler->loadProfile($tokenData['token']);
0 ignored issues
show
Bug introduced by
The method loadProfile() does not exist on null. ( Ignorable by Annotation )

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

51
            /** @scrutinizer ignore-call */ 
52
            $profile = $this->profiler->loadProfile($tokenData['token']);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52 1
            $graphql = $profile ? $profile->getCollector('graphql') : null;
53 1
            $tokenData['graphql'] = $graphql;
54
55 1
            return $tokenData;
56 1
        }, $this->profiler->find(null, $this->queryMatch ?: $this->endpointUrl, '100', 'POST', null, null, null));
57
58 1
        $schemas = [];
59 1
        foreach ($this->requestExecutor->getSchemasNames() as $schemaName) {
60 1
            $schemas[$schemaName] = SchemaPrinter::doPrint($this->requestExecutor->getSchema($schemaName));
61
        }
62
63 1
        return new Response($this->twig->render('@OverblogGraphQL/profiler/graphql.html.twig', [
64 1
            'request' => $request,
65 1
            'profile' => $profile,
66 1
            'tokens' => $tokens,
67 1
            'token' => $token,
68
            'panel' => null,
69 1
            'schemas' => $schemas,
70 1
        ]), 200, ['Content-Type' => 'text/html']);
71
    }
72
}
73