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

Autoloader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 34
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\Autoloader;
6
7
use ProxyManager\FileLocator\FileLocatorInterface;
8
use ProxyManager\Inflector\ClassNameInflectorInterface;
9
use function class_exists;
10
use function file_exists;
11
12
/**
13
 * {@inheritDoc}
14
 */
15
class Autoloader implements AutoloaderInterface
16
{
17
    protected FileLocatorInterface $fileLocator;
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
    protected ClassNameInflectorInterface $classNameInflector;
19
20
    public function __construct(FileLocatorInterface $fileLocator, ClassNameInflectorInterface $classNameInflector)
21
    {
22
        $this->fileLocator        = $fileLocator;
23
        $this->classNameInflector = $classNameInflector;
24 4
    }
25
26 4
    /**
27 4
     * {@inheritDoc}
28 4
     */
29
    public function __invoke(string $className) : bool
30
    {
31
        if (class_exists($className, false) || ! $this->classNameInflector->isProxyClassName($className)) {
32
            return false;
33 4
        }
34
35 4
        $file = $this->fileLocator->getProxyFileName($className);
36 2
37
        if (! file_exists($file)) {
38
            return false;
39 2
        }
40
41 2
        /* @noinspection PhpIncludeInspection */
42 1
        /* @noinspection UsingInclusionOnceReturnValueInspection */
43
        return (bool) require_once $file;
44
    }
45
}
46