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
Pull Request — master (#536)
by
unknown
20:28
created

Formatter::onErrorFormatting()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
c 2
b 0
f 0
dl 0
loc 16
rs 9.9666
cc 3
nc 3
nop 1
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
    public function onErrorFormatting(ErrorFormattingEvent $event): void
23
    {
24
        $error = $event->getError()->getPrevious();
25
26
        if ($error instanceof ArgumentsValidationException) {
27
            $validation = [];
28
29
            foreach ($error->getViolations() as $violation) {
30
                $validation[$violation->getPropertyPath()][] = [
31
                    'message' => $violation->getMessage(),
32
                    'code' => $violation->getCode(),
33
                ];
34
            }
35
36
            $formattedError = $event->getFormattedError();
37
            $formattedError['extensions']['validation'] = $validation;
38
        }
39
    }
40
}
41