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

Collection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getItems() 0 4 1
A toArray() 0 13 3
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