Collection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getItems() 0 3 1
A toArray() 0 12 3
1
<?php
2
3
namespace Rawilk\LaravelModules;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
use Illuminate\Support\Collection as BaseCollection;
7
8
class Collection extends BaseCollection
9
{
10
    public function getItems(): array
11
    {
12
        return $this->items;
13
    }
14
15
    public function toArray(): array
16
    {
17
        return array_map(static function ($value) {
18
            if ($value instanceof Module) {
19
                $attributes = $value->json()->getAttributes();
20
                $attributes['path'] = $value->getPath();
21
22
                return $attributes;
23
            }
24
25
            return $value instanceof Arrayable ? $value->toArray() : $value;
26
        }, $this->items);
27
    }
28
}
29