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 (#34)
by Jérémiah
12:28
created

Executor   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 7
Bugs 2 Features 3
Metric Value
wmc 8
c 7
b 2
f 3
lcom 1
cbo 7
dl 0
loc 72
ccs 34
cts 34
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A setMaxQueryDepth() 0 6 1
A setMaxQueryComplexity() 0 6 1
A setThrowException() 0 6 1
B execute() 0 22 4
1
<?php
2
3
/*
4
 * This file is part of the OverblogGraphQLBundle package.
5
 *
6
 * (c) Overblog <http://github.com/overblog/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Overblog\GraphQLBundle\Request;
13
14
use GraphQL\GraphQL;
15
use GraphQL\Language\Source;
16
use GraphQL\Schema;
17
use GraphQL\Validator\DocumentValidator;
18
use GraphQL\Validator\Rules\QueryComplexity;
19
use GraphQL\Validator\Rules\QueryDepth;
20
use Overblog\GraphQLBundle\Error\ErrorHandler;
21
use Overblog\GraphQLBundle\Event\Events;
22
use Overblog\GraphQLBundle\Event\ExecutorContextEvent;
23
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
24
25
class Executor
26
{
27
    private $schema;
28
29
    /**
30
     * @var EventDispatcherInterface|null
31
     */
32
    private $dispatcher;
33
34
    /** @var bool */
35
    private $throwException;
36
37
    /** @var ErrorHandler|null */
38
    private $errorHandler;
39
40 36
    public function __construct(Schema $schema, EventDispatcherInterface $dispatcher = null, $throwException = false, ErrorHandler $errorHandler = null)
41
    {
42 36
        $this->schema = $schema;
43 36
        $this->dispatcher = $dispatcher;
44 36
        $this->throwException = (bool) $throwException;
45 36
        $this->errorHandler = $errorHandler;
46 36
    }
47
48 36
    public function setMaxQueryDepth($maxQueryDepth)
49
    {
50
        /** @var QueryDepth $queryDepth */
51 36
        $queryDepth = DocumentValidator::getRule('QueryDepth');
52 36
        $queryDepth->setMaxQueryDepth($maxQueryDepth);
53 36
    }
54
55 36
    public function setMaxQueryComplexity($maxQueryComplexity)
56
    {
57
        /** @var QueryComplexity $queryComplexity */
58 36
        $queryComplexity = DocumentValidator::getRule('QueryComplexity');
59 36
        $queryComplexity->setMaxQueryComplexity($maxQueryComplexity);
60 36
    }
61
62
    /**
63
     * @param bool $throwException
64
     *
65
     * @return $this
66
     */
67 22
    public function setThrowException($throwException)
68
    {
69 22
        $this->throwException = (bool) $throwException;
70
71 22
        return $this;
72
    }
73
74 36
    public function execute(array $data, array $context = [])
75
    {
76 36
        if (null !== $this->dispatcher) {
77 36
            $event = new ExecutorContextEvent($context);
78 36
            $this->dispatcher->dispatch(Events::EXECUTOR_CONTEXT, $event);
79 36
            $context = $event->getExecutorContext();
80 36
        }
81
82 36
        $executionResult = GraphQL::executeAndReturnResult(
83 36
            $this->schema,
84 36
            isset($data['query']) ? $data['query'] : null,
85 36
            $context,
86 36
            $data['variables'],
87 36
            $data['operationName']
88 36
        );
89
90 36
        if (null !== $this->errorHandler) {
91 36
            $this->errorHandler->handleErrors($executionResult, $this->throwException);
92 36
        }
93
94 36
        return $executionResult;
95
    }
96
}
97