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 (#638)
by Vincent
26:04 queued 01:02
created

ProfilerController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 5
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\HttpFoundation\Request;
10
use Symfony\Component\HttpFoundation\Response;
11
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
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;
19
    private $twig;
20
    private $endpointUrl;
21
    private $requestExecutor;
22
    private $queryMatch;
23
24
    public function __construct(Profiler $profiler = null, Environment $twig = null, RouterInterface $router, RequestExecutor $requestExecutor, string $queryMatch = null)
25
    {
26
        $this->profiler = $profiler;
27
        $this->twig = $twig;
28
        $this->endpointUrl = $router->generate('overblog_graphql_endpoint');
29
        $this->requestExecutor = $requestExecutor;
30
        $this->queryMatch = $queryMatch;
31
    }
32
33
    public function __invoke(Request $request, $token)
34
    {
35
        if (null === $this->profiler) {
36
            throw new NotFoundHttpException('The profiler must be enabled.');
37
        }
38
39
        $this->profiler->disable();
40
41
        $profile = $this->profiler->loadProfile($token);
42
43
        $tokens = \array_map(function ($tokenData) {
44
            $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

44
            /** @scrutinizer ignore-call */ 
45
            $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...
45
            $graphql = $profile ? $profile->getCollector('graphql') : null;
46
            $tokenData['graphql'] = $graphql;
47
48
            return $tokenData;
49
        }, $this->profiler->find(null, $this->queryMatch ?: $this->endpointUrl, '100', 'POST', null, null, null));
50
51
        $schemas = [];
52
        foreach ($this->requestExecutor->getSchemasNames() as $schemaName) {
53
            $schemas[$schemaName] = SchemaPrinter::doPrint($this->requestExecutor->getSchema($schemaName));
54
        }
55
56
        return new Response($this->twig->render('@OverblogGraphQL/profiler/graphql.html.twig', [
0 ignored issues
show
Bug introduced by
The method render() 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

56
        return new Response($this->twig->/** @scrutinizer ignore-call */ render('@OverblogGraphQL/profiler/graphql.html.twig', [

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...
57
            'request' => $request,
58
            'profile' => $profile,
59
            'tokens' => $tokens,
60
            'token' => $token,
61
            'panel' => null,
62
            'schemas' => $schemas,
63
        ]), 200, ['Content-Type' => 'text/html']);
64
    }
65
}
66