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
Push — master ( d46d29...eb6a59 )
by Cees-Jan
03:22 queued 01:01
created

Mapper   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 48
ccs 0
cts 33
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B map() 0 34 5
A mapInstanciated() 0 10 2
1
<?php
2
3
namespace WyriHaximus\Tactician\CommandHandler;
4
5
use Doctrine\Common\Annotations\AnnotationReader;
6
use RecursiveDirectoryIterator;
7
use RecursiveIteratorIterator;
8
use ReflectionClass;
9
use WyriHaximus\Tactician\CommandHandler\Annotations\Handler;
10
11
final class Mapper
12
{
13
    public static function map($path, $namespace)
14
    {
15
        $reader = new AnnotationReader();
16
        $mapping = [];
17
18
        $directory = new RecursiveDirectoryIterator($path);
19
        $directory = new RecursiveIteratorIterator($directory);
20
21
        foreach ($directory as $node) {
22
            if (!is_file($node->getPathname())) {
23
                continue;
24
            }
25
26
            $file = substr($node->getPathname(), strlen($path));
27
            $file = ltrim($file, DIRECTORY_SEPARATOR);
28
            $file = rtrim($file, '.php');
29
30
            $class = $namespace . '\\' . str_replace(DIRECTORY_SEPARATOR, '\\', $file);
31
32
            if (!class_exists($class)) {
33
                continue;
34
            }
35
36
            $annotation = $reader->getClassAnnotation(new ReflectionClass($class), Handler::class);
37
38
            if (!($annotation instanceof Handler)) {
39
                continue;
40
            }
41
42
            $mapping[$class] = $annotation->getHandler();
43
        }
44
45
        return $mapping;
46
    }
47
48
    public static function mapInstanciated($path, $namespace)
49
    {
50
        $mapping = [];
51
52
        foreach (self::map($path, $namespace) as $command => $handler) {
53
            $mapping[$command] = new $handler();
54
        }
55
56
        return $mapping;
57
    }
58
}
59