Ejemplo n.º 1
0
 function let()
 {
     $variableCollection = new VariableCollection();
     foreach (self::$variablesArray as $variableString) {
         $variableCollection->addFromStringNotation($variableString);
     }
     $this->beConstructedWith(self::CLASS_NAME, self::NAME_SPACE, $variableCollection);
 }
Ejemplo n.º 2
0
 private function generate($fqcn, $variables)
 {
     $className = $this->getClassName($fqcn);
     $nameSpace = $this->getNameSpace($fqcn);
     $variableCollection = new VariableCollection();
     foreach ($variables as $variableString) {
         $variableCollection->addFromStringNotation($variableString);
     }
     if (count($variableCollection) == 0) {
         throw new Exception('Missed variable argument');
     }
     $generator = new EntityClassGenerator($className, $nameSpace, $variableCollection);
     $directory = getcwd() . '/' . $this->getPath($fqcn);
     if (is_dir($directory) && !is_writable($directory)) {
         throw new Exception(sprintf('The "%s" directory is not writable', $directory));
     }
     if (!is_dir($directory)) {
         mkdir($directory, 0777, true);
     }
     // TODO: Implement file name customization
     file_put_contents($directory . '/' . $className . '.php', $generator->generate());
     return "Done!";
 }