Passed
Push — master ( d44e36...c2d6d5 )
by Johnny
02:21
created

getTests()   A

Complexity

Conditions 5
Paths 8

Size

Total Lines 30
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 9
c 0
b 0
f 0
nc 8
nop 1
dl 0
loc 30
rs 9.6111
1
<?php
2
/*
3
 * This file is part of RSTS
4
 *
5
 * (c) Johnny Mast <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace App;
12
13
use RecursiveDirectoryIterator;
14
use RecursiveIteratorIterator;
15
16
/**
17
 * Get a list of test files.
18
 *
19
 * @param string $path The directory to read.
20
 *
21
 * @return array|void
22
 */
23
function getTests(string $path): array
24
{
25
    $files = [];
26
    //  $iterator = new RecursiveDirectoryIterator($path) or die(__FUNCTION__ . ": Failed opening directory {$path} for reading");
27
    $iterator = new TestCaseFilter(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path))) or
28
    die(__FUNCTION__ . ": Failed opening directory {$path} for reading");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
29
30
31
    foreach ($iterator as $file) {
32
33
        if ($file->isDir() === true) {
34
            continue;
35
        }
36
37
        // Fout
38
        //
39
        // begin.yml
40
        // replies.yml
41
        // triggers.yml
42
        // test-spec.yml
43
44
        if ($file->getBasename() !== 'rep.yml') {
45
            //    continue;
46
        }
47
48
49
        $files[] = $file->getPathname();
50
    }
51
52
    return $files;
53
}
54