Results   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 2
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addItem() 0 6 1
A orderBy() 0 5 1
1
<?php
2
namespace EngineWorks\Pivot;
3
4
class Results extends Collection
5
{
6
    protected $itemsInstanceOf = Result::class;
7
8
    /** @var Result */
9
    private $parent;
10
11 10
    public function __construct(Result $parent)
12
    {
13 10
        $this->parent = $parent;
14 10
    }
15
16 8
    public function addItem($item, $key = null)
17
    {
18
        /* @var Result $item */
19 8
        $item->parent = $this->parent;
20 8
        return parent::addItem($item, $key);
21
    }
22
23 4
    public function orderBy(ResultOrdering $ordering)
24
    {
25
        // uasort — Sort an array with a user-defined comparison function and maintain index association
26 4
        uasort($this->items, [$ordering, 'orderItems']);
27 4
    }
28
}
29