ASources   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 16
dl 0
loc 38
ccs 15
cts 15
cp 1
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setOrdering() 0 5 2
A wantDeep() 0 4 1
A getRoot() 0 3 1
A setFilterCallback() 0 4 1
A setStartPath() 0 4 1
1
<?php
2
3
namespace kalanis\kw_tree\DataSources;
4
5
6
use kalanis\kw_tree\Essentials\FileNode;
7
use kalanis\kw_tree\Interfaces\ITree;
8
9
10
abstract class ASources implements ITree
11
{
12
    /** @var string[] */
13
    protected array $startPath = [];
14
    protected string $ordering = ITree::ORDER_NONE;
15
    /** @var callable|null */
16
    protected $filterCallback = null;
17
    protected bool $recursive = false;
18
    protected ?FileNode $startNode = null;
19
20 5
    public function setStartPath(array $path): ITree
21
    {
22 5
        $this->startPath = $path;
23 5
        return $this;
24
    }
25
26 9
    public function setOrdering(string $order, ?string $by = null): ITree
27
    {
28 9
        $order = strtoupper($order);
29 9
        $this->ordering = in_array($order, [ITree::ORDER_NONE, ITree::ORDER_DESC, ITree::ORDER_ASC]) ? $order : $this->ordering;
30 9
        return $this;
31
    }
32
33 5
    public function setFilterCallback($callback): ITree
34
    {
35 5
        $this->filterCallback = $callback;
36 5
        return $this;
37
    }
38
39 7
    public function wantDeep(bool $want): ITree
40
    {
41 7
        $this->recursive = $want;
42 7
        return $this;
43
    }
44
45 11
    public function getRoot(): ?FileNode
46
    {
47 11
        return $this->startNode;
48
    }
49
}
50