Completed
Push — master ( 3be072...ba2d3a )
by Marco
231:32 queued 209:55
created

FileLocator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 27
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0
ccs 8
cts 8
cp 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\FileLocator;
6
7
use ProxyManager\Exception\InvalidProxyDirectoryException;
8
use const DIRECTORY_SEPARATOR;
9
use function realpath;
10
use function str_replace;
11
12
/**
13
 * {@inheritDoc}
14
 */
15
class FileLocator implements FileLocatorInterface
16
{
17
    protected string $proxiesDirectory;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
18
19
    /**
20
     * @throws InvalidProxyDirectoryException
21
     */
22
    public function __construct(string $proxiesDirectory)
23
    {
24
        $absolutePath = realpath($proxiesDirectory);
25 2
26
        if ($absolutePath === false) {
27 2
            throw InvalidProxyDirectoryException::proxyDirectoryNotFound($proxiesDirectory);
28
        }
29 2
30 1
        $this->proxiesDirectory = $absolutePath;
31
    }
32
33 1
    /**
34 1
     * {@inheritDoc}
35
     */
36
    public function getProxyFileName(string $className) : string
37
    {
38
        return $this->proxiesDirectory . DIRECTORY_SEPARATOR . str_replace('\\', '', $className) . '.php';
39 1
    }
40
}
41