TFilesFiles   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A filesExtCallback() 0 6 3
1
<?php
2
3
namespace kalanis\kw_tree\Traits;
4
5
6
use kalanis\kw_files\Node;
7
use kalanis\kw_paths\ArrayPath;
8
use kalanis\kw_paths\Stuff;
9
10
11
/**
12
 * Trait TFilesFiles
13
 * @package kalanis\kw_tree\Traits
14
 * Prepared callbacks for usage with data sources
15
 * Return nodes identified as dirs or files with predefined ext; use with deep tree lookup
16
 */
17
trait TFilesFiles
18
{
19 5
    public function filesExtCallback(Node $node): bool
20
    {
21 5
        $arrPt = new ArrayPath();
22 5
        $arrPt->setArray($node->getPath());
23 5
        $ext = Stuff::fileExt($arrPt->getFileName());
24 5
        return $node->isDir() || ($node->isFile() && in_array($ext, $this->whichExtsIWant()));
25
    }
26
27
    /**
28
     * @return string[]
29
     */
30
    abstract protected function whichExtsIWant(): array;
31
}
32