ModuleDetector::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
/**
3
 * @copyright 2018 Aleksander Stelmaczonek <[email protected]>
4
 * @license   MIT License, see license file distributed with this source code
5
 */
6
7
namespace Koriit\PHPDeps\Modules;
8
9
class ModuleDetector
10
{
11
    /** @var string */
12
    private $namespace;
13
14
    /** @var string */
15
    private $path;
16
17
    public function __construct($namespace, $path)
18
    {
19
        $this->namespace = $namespace;
20
        $this->path = $path;
21
    }
22
23
    public function getNamespace()
24
    {
25
        return $this->namespace;
26
    }
27
28
    public function getPath()
29
    {
30
        return $this->path;
31
    }
32
33
    /**
34
     * @return Module[]
35
     */
36
    public function findModules()
37
    {
38
        $modules = [];
39
40
        foreach (\glob($this->path . '/*', GLOB_ONLYDIR) as $modulePath) {
41
            $name = \basename($modulePath);
42
            $modules[] = new Module($name, $this->namespace . '\\' . $name, $modulePath);
43
        }
44
45
        return $modules;
46
    }
47
}
48