Completed
Push — master ( 419c88...940d42 )
by Nicolas
03:31
created

Collection::toArray()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

Changes 0
Metric Value
cc 3
nc 1
nop 0
dl 0
loc 13
ccs 6
cts 7
cp 0.8571
crap 3.0261
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace Nwidart\Modules;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
use Illuminate\Support\Collection as BaseCollection;
7
8
class Collection extends BaseCollection
9
{
10
    /**
11
     * Get items collections.
12
     *
13
     * @return array
14
     */
15 1
    public function getItems()
16
    {
17 1
        return $this->items;
18
    }
19
20
    /**
21
     * Get the collection of items as a plain array.
22
     *
23
     * @return array
24
     */
25 1
    public function toArray()
26
    {
27
        return array_map(function ($value) {
28 1
            if ($value instanceof Module) {
29 1
                $attributes = $value->json()->getAttributes();
30 1
                $attributes["path"] = $value->getPath();
31
32 1
                return $attributes;
33
            }
34
35
            return $value instanceof Arrayable ? $value->toArray() : $value;
0 ignored issues
show
Bug introduced by
The class Illuminate\Contracts\Support\Arrayable does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
36 1
        }, $this->items);
37
    }
38
}
39