Example #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);
 }
Example #2
0
 public function testSetFilePath()
 {
     $this->class->setFilePath(__DIR__ . '/../MyFile.php');
     $this->assertSame(Path::canonicalize(__DIR__ . '/..'), $this->class->getDirectory());
     $this->assertSame('MyFile.php', $this->class->getFileName());
 }