GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — master ( e039e4...016889 )
by Gabriel
04:43
created

TransformMethodsTrait::toArray()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Collections\Traits;
4
5
use JsonSerializable;
6
use Nip\Collections\AbstractCollection;
7
8
/**
9
 * Class TransformMethodsTrait
10
 * @package Nip\Collections\Traits
11
 */
12
trait TransformMethodsTrait
13
{
14
15
    /**
16
     * @return array
17
     */
18
    public function toArray()
19
    {
20
        return array_map(function ($value) {
21
            return $value instanceof AbstractCollection ? $value->toArray() : $value;
22
        }, $this->items);
0 ignored issues
show
Bug introduced by
The property items 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...
23
    }
24
25
    /**
26
     * Specify data which should be serialized to JSON
27
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
28
     * @return mixed data which can be serialized by <b>json_encode</b>,
29
     * which is a value of any type other than a resource.
30
     * @since 5.4.0
31
     */
32
    function jsonSerialize()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
    {
34
        return array_map(function ($value) {
35
            if ($value instanceof JsonSerializable) {
0 ignored issues
show
Bug introduced by
The class JsonSerializable does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
36
                return $value->jsonSerialize();
37
            } else {
38
                return $value;
39
            }
40
        }, $this->items);
41
    }
42
}
43