LTreeResourceCollection::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 4
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Umbrellio\LTree\Resources;
6
7
use Illuminate\Http\Resources\Json\ResourceCollection;
8
use Illuminate\Support\Collection;
9
use Umbrellio\LTree\Collections\LTreeCollection;
10
11
abstract class LTreeResourceCollection extends ResourceCollection
12
{
13
    /**
14
     * @param LTreeCollection|Collection $resource
15
     */
16 1
    public function __construct($resource, $sort = null, bool $usingSort = true, bool $loadMissing = true)
17
    {
18 1
        $collection = $resource->toTree($usingSort, $loadMissing);
19
20 1
        if ($sort) {
21 1
            $collection->sortTree($sort);
22
        }
23
24 1
        parent::__construct($collection->getChildren());
25
    }
26
}
27