| 1 | <?php |
||
| 15 | class Autoloader implements AutoloaderInterface |
||
| 16 | { |
||
| 17 | protected FileLocatorInterface $fileLocator; |
||
|
|
|||
| 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 |