FileHelper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getListOfAllPHPFiles() 0 18 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Todolo\Helper;
6
7
use RecursiveDirectoryIterator;
8
use RecursiveIteratorIterator;
9
10
class FileHelper
11
{
12
    /**
13
     * @return array<string>
14
     */
15 2
    public function getListOfAllPHPFiles(string $dir): array
16
    {
17 2
        $result = [];
18
19 2
        $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
20
21 2
        foreach ($rii as $file) {
22 2
            if ($file->isFile() && str_contains($file->getFilename(), '.php')) {
23 2
                $fullpath = $file->getPath().'/'.$file->getFilename();
24
25
                // remove given dir from fullpath
26 2
                $fullpath = str_replace($dir, '', $fullpath);
27
28 2
                $result[] = $fullpath;
29
            }
30
        }
31
32 2
        return $result;
33
    }
34
}
35