GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#1)
by Saif Eddin
08:53
created

functions.php ➔ listClassesInDirecories()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 15
ccs 4
cts 4
cp 1
crap 2
rs 9.7666
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus;
4
5
use Roave\BetterReflection\BetterReflection;
6
use Roave\BetterReflection\Reflector\ClassReflector;
7
use Roave\BetterReflection\SourceLocator\Type\AggregateSourceLocator;
8
use Roave\BetterReflection\SourceLocator\Type\AutoloadSourceLocator;
9
use Roave\BetterReflection\SourceLocator\Type\DirectoriesSourceLocator;
10
11
/**
12
 * get a list of all classes in the given direcotories.
13
 *
14
 * Based on: https://github.com/Roave/BetterReflection/blob/396a07c9d276cb9ffba581b24b2dadbb542d542e/demo/parsing-whole-directory/example2.php.
15
 * 
16 1
 * @param  array<int, string>  $directories
17 1
 *
18 1
 * @return iterable
19 1
 */
20
function listClassesInDirecories(string ...$directories): iterable
21
{
22 1
    $sourceLocator = new AggregateSourceLocator([
23
        new DirectoriesSourceLocator(
24
            $directories,
25 1
            (new BetterReflection())->astLocator()
26 1
        ),
27
        // ↓ required to autoload parent classes/interface from another directory than /src (e.g. /vendor)
28 1
        new AutoloadSourceLocator((new BetterReflection())->astLocator()),
29
    ]);
30
31
    foreach ((new ClassReflector($sourceLocator))->getAllClasses() as $class) {
32
        yield $class->getName();
33
    }
34
}
35
36
/**
37
 * get a list of all classes in the given direcotory.
38
 *
39
 * Based on: https://github.com/Roave/BetterReflection/blob/396a07c9d276cb9ffba581b24b2dadbb542d542e/demo/parsing-whole-directory/example2.php.
40
 * 
41
 * @param  string $directory
42
 *
43
 * @return iterable
44
 */
45
function listClassesInDirectory(string $directory): iterable
46
{
47
    return listClassesInDirecories($directory);
48
}
49