Volume   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 24
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A filterHtml() 0 3 1
A getFiles() 0 6 2
1
<?php
2
3
namespace kalanis\kw_menu\EntriesSource;
4
5
6
use kalanis\kw_menu\Interfaces\IEntriesSource;
7
use kalanis\kw_menu\Traits\TFilterHtml;
8
use kalanis\kw_paths\Stuff;
9
use Traversable;
10
11
12
/**
13
 * Class Volume
14
 * @package kalanis\kw_menu\EntriesSource
15
 * Entries source is processed directly over volume
16
 */
17
class Volume implements IEntriesSource
18
{
19
    use TFilterHtml;
20
21
    /** @var string path to menu dir */
22
    protected string $rootPath = '';
23
24 5
    public function __construct(string $rootPath)
25
    {
26 5
        $this->rootPath = Stuff::removeEndingSlash($rootPath) . DIRECTORY_SEPARATOR;
27 5
    }
28
29 3
    public function getFiles(array $path): Traversable
30
    {
31 3
        $dir = Stuff::arrayToPath($path);
32 3
        $list = scandir($this->rootPath . $dir);
33 3
        if (false !== $list) {
34 3
            yield from array_filter(array_filter($list, [Stuff::class, 'notDots']), [$this, 'filterHtml']);
35
        }
36 3
    }
37
38 3
    public function filterHtml(string $fileName): bool
39
    {
40 3
        return $this->filterExt(Stuff::fileExt($fileName));
41
    }
42
}
43