/**
  * @param string $zephirCode
  *
  * @throws \Exception
  */
 public function isValid($namespace)
 {
     if (!defined('ZEPHIRPATH')) {
         define('ZEPHIRPATH', realpath(__DIR__ . '/../../vendor/phalcon/zephir') . '/');
     }
     $generateCommand = new CommandGenerate();
     $cleanCommand = new CommandFullClean();
     try {
         $config = new Config();
         $config->set('namespace', $namespace);
         $config->set('silent', true);
         $cleanCommand->execute($config, new ZephirLogger($config));
         $generateCommand->execute($config, new ZephirLogger($config));
     } catch (CompilerException $e) {
         throw new \Exception(sprintf('Error on %s', $e->getMessage()));
     }
     return true;
 }
 /**
  * Build a zephir extension and return the extension path
  *
  * @param string  $zephir
  * @param boolean $silent
  * @throws \Exception
  * @return string
  */
 public function build($zephir, $silent)
 {
     $dto = $this->zephirClassInfo->getZephirCodeInfo($zephir);
     $this->fileWorker->writeZephirFile($dto, $zephir);
     $this->defineZephirHome();
     try {
         $config = new Config();
         $config->set('namespace', $dto->getExtensionName());
         $config->set('silent', $silent);
         if (is_dir('ext')) {
             $this->commandFullClean->execute($config, new ZephirLogger($config));
         }
         $this->commandBuild->execute($config, new ZephirLogger($config));
     } catch (\Exception $e) {
         $this->fileWorker->rmdirRecursive($dto->getBaseDir());
         throw new \Exception(sprintf('Error on %s', $e->getMessage()));
     }
     return 'ext/modules/' . $dto->getExtensionName() . '.so';
 }
 /**
  * @param string $zephirCode
  *
  * @throws \Exception
  */
 public function isValid($namespace)
 {
     $currentDir = getcwd();
     chdir(FileWriter::BASE_DESTINATION . $namespace);
     if (!defined('ZEPHIRPATH')) {
         define('ZEPHIRPATH', realpath(__DIR__ . '/../../vendor/phalcon/zephir') . '/');
     }
     $generateCommand = new CommandGenerate();
     $cleanCommand = new CommandFullClean();
     try {
         $config = new Config();
         $config->set('namespace', strtolower($namespace));
         $config->set('silent', true);
         if (is_dir('ext')) {
             $cleanCommand->execute($config, new ZephirLogger($config));
         }
         $generateCommand->execute($config, new ZephirLogger($config));
     } catch (Exception $e) {
         chdir($currentDir);
         throw new \Exception(sprintf('Error on %s', $e->getMessage()));
     }
     chdir($currentDir);
     return true;
 }