allClasses[] = $this->transformPathToClass($path); } private function loadClasses(): void { $recursiveDirectoryIterator = new \RecursiveDirectoryIterator(self::FOLDER); $files = new \RecursiveIteratorIterator($recursiveDirectoryIterator, \RecursiveIteratorIterator::SELF_FIRST); foreach ($files as $file) { $path = $file->getPathname(); if ($this->isPHP($path) && !$this->isInterface($path)) { $this->addToClasses($path); } } } public function __construct() { $this->loadClasses(); } /** * @param string $subPath * @param string $rootPath * * @return bool */ private function isSubSourceClass(string $subPath, string $rootPath): bool { return substr($rootPath, 0, strlen($subPath)) === $subPath; } /** * {@inheritdoc} * * @see \Infinito\Domain\SourceManagement\SourceClassInformationServiceInterface::getAllSourceClasses() */ public function getAllSourceClasses(): array { return $this->allClasses; } /** * {@inheritdoc} * * @see \Infinito\Domain\SourceManagement\SourceClassInformationServiceInterface::getAllSubSourceClasses() */ public function getAllSubSourceClasses(string $subNamespace): array { $subSourceClasses = []; foreach ($this->allClasses as $class) { if ($this->isSubSourceClass($subNamespace, $class)) { $subSourceClasses[] = $class; } } return $subSourceClasses; } }