/**
  * Return the class name and the namespace of a zephir code
  *
  * @param string $zephir
  * @return array
  */
 public function getZephirCodeInfo($zephir)
 {
     $dto = new ZephirClassInfoDto();
     $dto->setClassName($this->findAttribut('/class (\\w+)/', "Unable to find class name", $zephir));
     $dto->setNamespace($this->findAttribut("/namespace ([A-z0-9\\\\]+)/", "Unable to find namespace", $zephir));
     return $dto;
 }
Example #2
0
 /**
  * @param ZephirClassInfoDto $dto
  * @param string $code
  * @throws \Exception
  * @return void
  */
 public function writeZephirFile(ZephirClassInfoDto $dto, $code)
 {
     $this->rmdirRecursive($dto->getBaseDir());
     if (@mkdir(getcwd() . '/' . $dto->getDir(), 0777, true) === false) {
         throw new \Exception('could not create dir ' . getcwd() . '/' . $dto->getDir());
     }
     file_put_contents($dto->getFilePath() . '.zep', $code);
 }