Completed
Push — master ( 9e1ab8...e0f7b9 )
by Bill
04:14 queued 02:03
created

FileManager::getPhpFiles()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 1
1
<?php declare(strict_types = 1);
2
3
namespace Churn\Managers;
4
5
use RecursiveDirectoryIterator;
6
use RecursiveIteratorIterator;
7
8
class FileManager
9
{
10
    /**
11
     * Recursively finds all files with the .php extension in the provided
12
     * $path and returns list as array.
13
     * @param  string $path Path to look for .php files.
14
     * @return array
15
     */
16
    public function getPhpFiles(string $path): array
17
    {
18
        $directoryIterator = new RecursiveDirectoryIterator($path);
19
        $files = [];
20
        foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
21
            if ($file->getExtension() !== 'php') {
22
                continue;
23
            }
24
            $files[] = $file->getRealPath();
25
        }
26
        return $files;
27
    }
28
}
29