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

Passed
Push — master ( 83db66...8ac73c )
by Jérémiah
21:08
created

Formatter::onErrorFormatting()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 9.9666
c 1
b 0
f 0
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Validator;
6
7
use Overblog\GraphQLBundle\Event\ErrorFormattingEvent;
8
use Overblog\GraphQLBundle\Validator\Exception\ArgumentsValidationException;
9
10
/**
11
 * Class Formatter.
12
 *
13
 * Adds validation errors to the response.
14
 *
15
 * @see https://github.com/overblog/GraphQLBundle/blob/master/docs/validation/index.md#error-messages
16
 */
17
class Formatter
18
{
19
    /**
20
     * @param ErrorFormattingEvent $event
21
     */
22 26
    public function onErrorFormatting(ErrorFormattingEvent $event): void
23
    {
24 26
        $error = $event->getError()->getPrevious();
25
26 26
        if ($error instanceof ArgumentsValidationException) {
27 4
            $validation = [];
28
29 4
            foreach ($error->getViolations() as $violation) {
30 4
                $validation[$violation->getPropertyPath()][] = [
31 4
                    'message' => $violation->getMessage(),
32 4
                    'code' => $violation->getCode(),
33
                ];
34
            }
35
36 4
            $formattedError = $event->getFormattedError();
37 4
            $formattedError['extensions']['validation'] = $validation;
38
        }
39 26
    }
40
}
41