TFilesFiles::filesExtCallback()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0
cc 3
nc 3
nop 1
crap 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