Example #1
0
File: File.php Project: travisj/zf
 /**
  * setClass()
  *
  * @param Zend_CodeGenerator_Php_Class|array $class
  * @return Zend_CodeGenerator_Php_File
  */
 public function setClass($class)
 {
     if (is_array($class)) {
         $class = new Zend_CodeGenerator_Php_Class($class);
         $className = $class->getName();
     } elseif ($class instanceof Zend_CodeGenerator_Php_Class) {
         $className = $class->getName();
     } else {
         require_once 'Zend/CodeGenerator/Php/Exception.php';
         throw new Zend_CodeGenerator_Php_Exception('Expecting either an array or an instance of Zend_CodeGenerator_Php_Class');
     }
     // @todo check for dup here
     $this->_classes[$className] = $class;
     return $this;
 }
 public function testNameAccessors()
 {
     $codeGenClass = new Zend_CodeGenerator_Php_Class();
     $codeGenClass->setName('TestClass');
     $this->assertEquals($codeGenClass->getName(), 'TestClass');
 }
Example #3
0
 /**
  * Save specified class to it's relative file
  * Basically a wrapper for self::create(), which updates the file if it already exists
  *
  * @param	Zend_CodeGenerator_Php_Class	$class
  *
  * @return	Zend_CodeGenerator_Php_Class
  */
 public static function save(Zend_CodeGenerator_Php_Class $class)
 {
     $className = $class->getName();
     return self::create($className, $class);
 }