Пример #1
0
 /**
  * Writes a {@link Clazz} instance to a file.
  *
  * The directory of the class must have been set.
  *
  * @param Clazz $class The class to write.
  */
 public function writeClass(Clazz $class)
 {
     Assert::notEmpty($class->getDirectory(), 'The directory of the written class must not be empty.');
     ob_start();
     require __DIR__ . '/../../res/template/Class.tpl.php';
     $source = "<?php\n" . ob_get_clean();
     if (!file_exists($class->getDirectory())) {
         mkdir($class->getDirectory(), 0777, true);
     }
     file_put_contents($class->getFilePath(), $source);
 }
Пример #2
0
 public function testGetFilePath()
 {
     $this->class->setDirectory(__DIR__);
     $this->class->setFileName('MyFile.php');
     $this->assertSame(__DIR__ . '/MyFile.php', $this->class->getFilePath());
 }