Module::getPattern()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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 Module
10
{
11
    /** @var string */
12
    private $name;
13
14
    /** @var string */
15
    private $namespace;
16
17
    /** @var string */
18
    private $path;
19
20
    /** @var string */
21
    private $pattern;
22
23
    public function __construct($name, $namespace, $path)
24
    {
25
        $this->name = $name;
26
        $this->namespace = $namespace;
27
        $this->path = $path;
28
        $this->pattern = '/^' . \str_replace('\\', '\\\\', $namespace) . (\is_dir($path) ? '(\\\\.+)?' : '') . '$/';
29
    }
30
31
    public function getName()
32
    {
33
        return $this->name;
34
    }
35
36
    public function getNamespace()
37
    {
38
        return $this->namespace;
39
    }
40
41
    public function getPath()
42
    {
43
        return $this->path;
44
    }
45
46
    public function getPattern()
47
    {
48
        return $this->pattern;
49
    }
50
}
51