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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A format() 0 12 3
A __invoke() 0 4 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