Aggregates::getOrderArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 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