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

FieldsTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFields() 0 10 4
A getField() 0 9 2
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
use GraphQL\Type\Definition\Config;
15
use GraphQL\Utils;
16
17
trait FieldsTrait
18
{
19
    /**
20
     * @var FieldDefinition[]
21
     */
22
    private $_fields;
23
24
    /**
25
     * @return FieldDefinition[]
26
     */
27
    public function getFields()
28
    {
29
        if (null === $this->_fields) {
30
            $fields = isset($this->config['fields']) ? $this->config['fields'] : [];
0 ignored issues
show
Bug introduced by
The property config does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
31
            $fields = is_callable($fields) ? call_user_func($fields) : $fields;
32
            $this->_fields = FieldDefinition::createMap($fields);
33
        }
34
35
        return $this->_fields;
36
    }
37
38
    /**
39
     * @param string $name
40
     *
41
     * @return FieldDefinition
42
     *
43
     * @throws \Exception
44
     */
45
    public function getField($name)
46
    {
47
        if (null === $this->_fields) {
48
            $this->getFields();
49
        }
50
        Utils::invariant(isset($this->_fields[$name]), "Field '%s' is not defined for type '%s'", $name, $this->name);
0 ignored issues
show
Bug introduced by
The property name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
51
52
        return $this->_fields[$name];
53
    }
54
}
55