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 (#7)
by Jérémiah
09:24
created

MergeFieldTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 1
Metric Value
wmc 5
c 1
b 1
f 1
lcom 0
cbo 0
dl 0
loc 27
ccs 14
cts 14
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getFieldsWithDefaults() 0 24 5
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\Definition;
13
14
trait MergeFieldTrait
15
{
16
    protected function getFieldsWithDefaults($fields, array $defaultFields, $forceArray = true)
17
    {
18 18
        $callback = function () use ($fields, $defaultFields) {
19 18
            if (empty($fields)) {
20 14
                return $defaultFields;
21
            }
22
23 17
            if (is_callable($fields)) {
24 2
                $fields = $fields();
0 ignored issues
show
Bug introduced by
Consider using a different name than the imported variable $fields, or did you forget to import by reference?

It seems like you are assigning to a variable which was imported through a use statement which was not imported by reference.

For clarity, we suggest to use a different name or import by reference depending on whether you would like to have the change visibile in outer-scope.

Change not visible in outer-scope

$x = 1;
$callable = function() use ($x) {
    $x = 2; // Not visible in outer scope. If you would like this, how
            // about using a different variable name than $x?
};

$callable();
var_dump($x); // integer(1)

Change visible in outer-scope

$x = 1;
$callable = function() use (&$x) {
    $x = 2;
};

$callable();
var_dump($x); // integer(2)
Loading history...
25 2
            }
26
27 17
            if (!is_array($fields)) {
28 1
                $fields = (array) $fields;
0 ignored issues
show
Bug introduced by
Consider using a different name than the imported variable $fields, or did you forget to import by reference?

It seems like you are assigning to a variable which was imported through a use statement which was not imported by reference.

For clarity, we suggest to use a different name or import by reference depending on whether you would like to have the change visibile in outer-scope.

Change not visible in outer-scope

$x = 1;
$callable = function() use ($x) {
    $x = 2; // Not visible in outer scope. If you would like this, how
            // about using a different variable name than $x?
};

$callable();
var_dump($x); // integer(1)

Change visible in outer-scope

$x = 1;
$callable = function() use (&$x) {
    $x = 2;
};

$callable();
var_dump($x); // integer(2)
Loading history...
29 1
            }
30
31 17
            return array_merge($fields, $defaultFields);
32 18
        };
33
34 18
        if ($forceArray) {
35 17
            return $callback();
36
        } else {
37 1
            return $callback;
38
        }
39
    }
40
}
41