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

CustomErrorFormatter::format()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 3
eloc 7
nc 2
nop 1
1
<?php
2
3
namespace Overblog\GraphQLBundle\Tests\Error;
4
5
use GraphQL\Error\Error;
6
use GraphQL\Error\FormattedError;
7
8
class CustomErrorFormatter
9
{
10
    /**
11
     * @param \Error|\Exception $e
12
     *
13
     * @return array
14
     */
15
    public static function format($e)
16
    {
17
        $code = $e->getCode();
18
        if ($e instanceof Error && $e->getPrevious()) {
19
            $code = $e->getPrevious()->getCode();
20
        }
21
22
        $formattedError = FormattedError::createFromException($e);
0 ignored issues
show
Bug introduced by
It seems like $e defined by parameter $e on line 15 can also be of type object<Exception>; however, GraphQL\Error\FormattedE...::createFromException() does only seem to accept object<Throwable>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
23
        $formattedError['code'] = $code;
24
25
        return $formattedError;
26
    }
27
28
    /**
29
     * @param \Error|\Exception $e
30
     *
31
     * @return array
32
     */
33
    public function __invoke($e)
34
    {
35
        return static::format($e);
36
    }
37
}
38