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
21:16
created

ProfilerController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 30
c 1
b 0
f 0
dl 0
loc 46
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __invoke() 0 31 4
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;
0 ignored issues
show
Bug introduced by
The type Twig\Environment 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...
15
16
class ProfilerController
17
{
18
    private $profiler;
19
    private $twig;
20
    private $endpointUrl;
21
    private $requestExecutor;
22
23
    public function __construct(Profiler $profiler = null, Environment $twig = null, RouterInterface $router, RequestExecutor $requestExecutor)
24
    {
25
        $this->profiler = $profiler;
26
        $this->twig = $twig;
27
        $this->endpointUrl = $router->generate('overblog_graphql_endpoint');
28
        $this->requestExecutor = $requestExecutor;
29
    }
30
31
    public function __invoke(Request $request, $token)
32
    {
33
        if (null === $this->profiler) {
34
            throw new NotFoundHttpException('The profiler must be enabled.');
35
        }
36
37
        $this->profiler->disable();
38
39
        $profile = $this->profiler->loadProfile($token);
40
41
        $tokens = \array_map(function ($tokenData) {
42
            $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

42
            /** @scrutinizer ignore-call */ 
43
            $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...
43
            $graphql = $profile ? $profile->getCollector('graphql') : null;
44
            $tokenData['graphql'] = $graphql;
45
46
            return $tokenData;
47
        }, $this->profiler->find(null, $this->endpointUrl, '100', null, null, null, null));
48
49
        $schemas = [];
50
        foreach ($this->requestExecutor->getSchemasNames() as $schemaName) {
51
            $schemas[$schemaName] = SchemaPrinter::doPrint($this->requestExecutor->getSchema($schemaName));
52
        }
53
54
        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

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