/**
  * AbstractCommandQueryService constructor.
  *
  * @param                                                          $commandQueryName
  * @param                                                          $moduleName
  * @param \CodeMine\CommandQueryGenerator\Service\DirectoryService $directoryService
  */
 public function __construct($commandQueryName, $moduleName, DirectoryService $directoryService)
 {
     $this->commandQueryName = $commandQueryName;
     $this->modulePath = $directoryService->getPathForModule($moduleName);
     $this->moduleName = $moduleName;
     $this->directoryService = $directoryService;
 }
 /**
  * ConfigService constructor.
  *
  * @param                                                 $objectPath
  * @param \CodeMine\CommandQueryGenerator\Service\DirectoryService $directoryService
  */
 public function __construct($objectPath, DirectoryService $directoryService)
 {
     $this->objectPath = $objectPath;
     $this->directoryService = $directoryService;
     $configDir = $this->directoryService->getPathForAutoloadConfigs();
     $confPath = $configDir . DIRECTORY_SEPARATOR . self::CONFIG_NAME;
     $this->confPath = $confPath;
 }
 protected function createRealCommandQuery($commandPath, $name, $moduleName)
 {
     $this->directoryService->makeSureDirExist($commandPath);
     $this->directoryService->createAllNamespacedDir($name, $commandPath);
     $nameParts = explode('/', trim($name, '/'));
     $className = sprintf('%s%s', $nameParts[count($nameParts) - 1], $this->getSuffixClass());
     $handlerName = sprintf('%s%s', $className, 'Handler');
     $handlerFactoryName = sprintf('%s%s', $handlerName, 'Factory');
     unset($nameParts[count($nameParts) - 1]);
     //Set namespace for generated files
     $namespace = sprintf('%s\\%s\\%s', $moduleName, $this->getDirectory(), implode('\\', $nameParts));
     $classGenerator = new ClassGenerator();
     $classGenerator->setNamespaceName(trim($namespace, '\\'));
     $handlerGenerator = new ClassGenerator();
     $handlerGenerator->setNamespaceName(trim($namespace, '\\'));
     $handlerFactoryGenerator = new ClassGenerator();
     $handlerFactoryGenerator->setNamespaceName(trim($namespace, '\\'));
     //Set basic properties for command
     $commandQueryInterfaceToImplement = $this->getCommandQueryInterfaceToImplement();
     $classGenerator->setName($className);
     //        $classGenerator->addUse($commandQueryInterfaceToImplement);
     $tmpRef = new \ReflectionClass($commandQueryInterfaceToImplement);
     $classGenerator->setImplementedInterfaces([$tmpRef->getName()]);
     $this->addMethodsFromInterface($commandQueryInterfaceToImplement, $classGenerator);
     //Set basic properties for command handler
     $commandHandlerClassToImplement = $this->getAbstractHandlerClassName();
     $tmpRef = new \ReflectionClass($commandHandlerClassToImplement);
     $handlerGenerator->setName($handlerName);
     $handlerGenerator->setExtendedClass($tmpRef->getName());
     $this->addMethodsFromAbstractClass($commandHandlerClassToImplement, $handlerGenerator);
     //Set basic properties for command handler factory
     $commandHandlerFactoryClassToImplement = FactoryInterface::class;
     $handlerFactoryGenerator->setName($handlerFactoryName);
     $handlerFactoryGenerator->addUse($commandHandlerFactoryClassToImplement);
     $handlerFactoryGenerator->setImplementedInterfaces([FactoryInterface::class]);
     $this->addMethodsFromInterface($commandHandlerFactoryClassToImplement, $handlerFactoryGenerator);
     //        $method = $handlerFactoryGenerator->getMethod('__invoke');
     ////        $method->setParameters()
     //        $method->setBody(sprintf('return new %s();', $handlerGenerator->getName()));
     //GENERATE IT !!!
     $fileGenerator = FileGenerator::fromArray(['classes' => [$classGenerator]]);
     file_put_contents(sprintf('%s%s%s%s%s%s', $commandPath, DIRECTORY_SEPARATOR, implode(DIRECTORY_SEPARATOR, $nameParts), DIRECTORY_SEPARATOR, $className, '.php'), $fileGenerator->generate());
     $fileGenerator = FileGenerator::fromArray(['classes' => [$handlerGenerator]]);
     file_put_contents(sprintf('%s%s%s%s%s%s', $commandPath, DIRECTORY_SEPARATOR, implode(DIRECTORY_SEPARATOR, $nameParts), DIRECTORY_SEPARATOR, $handlerName, '.php'), $fileGenerator->generate());
     $fileGenerator = FileGenerator::fromArray(['classes' => [$handlerFactoryGenerator]]);
     file_put_contents(sprintf('%s%s%s%s%s%s', $commandPath, DIRECTORY_SEPARATOR, implode(DIRECTORY_SEPARATOR, $nameParts), DIRECTORY_SEPARATOR, $handlerFactoryName, '.php'), $fileGenerator->generate());
     return [sprintf('%s\\%s', $classGenerator->getNamespaceName(), $classGenerator->getName()), sprintf('%s\\%s', $handlerGenerator->getNamespaceName(), $handlerGenerator->getName()), sprintf('%s\\%s', $handlerFactoryGenerator->getNamespaceName(), $handlerFactoryGenerator->getName())];
 }