Checker   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 29
c 0
b 0
f 0
wmc 4
lcom 0
cbo 5
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 22 4
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Marcosh\PhpTypeChecker;
6
7
use Marcosh\PhpTypeChecker\TypeHint\InputTypeHint;
8
use Marcosh\PhpTypeChecker\TypeHint\ReturnTypeHint;
9
use Roave\BetterReflection\Reflection\ReflectionMethod;
10
use Roave\BetterReflection\Reflector\ClassReflector;
11
use Roave\BetterReflection\Reflector\FunctionReflector;
12
use Roave\BetterReflection\SourceLocator\Type\DirectoriesSourceLocator;
13
14
final class Checker
15
{
16
    /**
17
     * @param string $path to be checked
18
     * @return \Iterator
19
     */
20
    public function __invoke(string $path): \Iterator
21
    {
22
        $directoriesSourceLocator = new DirectoriesSourceLocator([$path]);
23
24
        $classReflector = new ClassReflector($directoriesSourceLocator);
25
26
        foreach($classReflector->getAllClasses() as $class) {
27
            $methods = $class->getImmediateMethods();
28
29
            foreach ($methods as $method) {
30
                yield from ReturnTypeHint::method($method);
31
                yield from InputTypeHint::method($method);
32
            }
33
        }
34
35
        $functionReflector = new FunctionReflector($directoriesSourceLocator);
36
37
        foreach ($functionReflector->getAllFunctions() as $function) {
38
            yield from ReturnTypeHint::function($function);
39
            yield from InputTypeHint::function($function);
40
        }
41
    }
42
}
43