Aggregates   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 33
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addItem() 0 5 1
A asArray() 0 9 2
A getOrderArray() 0 9 2
1
<?php
2
namespace EngineWorks\Pivot;
3
4
class Aggregates extends Collection
5
{
6
    protected $itemsInstanceOf = Aggregate::class;
7
8 12
    public function addItem($item, $key = null)
9
    {
10 12
        $key = $item->getAsname();
11 12
        return parent::addItem($item, $key);
12
    }
13
14 11
    public function asArray()
15
    {
16 11
        $a = [];
17 11
        foreach ($this->items as $item) {
18
            /* @var Aggregate $item */
19 11
            $a[] = $item->asArray();
20
        }
21 11
        return $a;
22
    }
23
24
    /**
25
     * @return array
26
     */
27 9
    public function getOrderArray()
28
    {
29 9
        $array = [];
30 9
        foreach ($this->items as $key => $item) {
31
            /* @var Aggregate $item */
32 9
            $array[$key] = $item->getOrder();
33
        }
34 9
        return $array;
35
    }
36
}
37