Completed
Push — master ( ce80e8...5094c0 )
by Nicolas
12:10
created

Collection::getItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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
    public function getItems()
16
    {
17
        return $this->items;
18
    }
19
20
    /**
21
     * Get the collection of items as a plain array.
22
     *
23
     * @return array
24
     */
25
    public function toArray()
26
    {
27 3
        return array_map(function ($value) {
28 3
            if ($value instanceof Module) {
29
                return $value->json()->getAttributes();
30
            }
31
32 3
            return $value instanceof Arrayable ? $value->toArray() : $value;
33
34 3
        }, $this->items);
35
    }
36
}
37