Exemplo n.º 1
0
 /**
  * setConstant()
  *
  * @param array|\Zend\CodeGenerator\Php\PhpProperty $const
  * @return Zend\CodeGenerator\Php\PhpClass
  */
 public function setConstant($const)
 {
     if (is_array($const)) {
         $const = new PhpProperty($const);
         $constName = $const->getName();
     } elseif ($const instanceof PhpProperty) {
         $constName = $const->getName();
     } else {
         throw new Exception\InvalidArgumentException('setConstant() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property');
     }
     if (!$const->isConst()) {
         throw new Exception\InvalidArgumentException('setProperty() expects argument to define a constant');
     }
     if (isset($this->_constants[$constName])) {
         throw new Exception\InvalidArgumentException('A constant by name ' . $constName . ' already exists in this class.');
     }
     $this->_constants[$constName] = $const;
     return $this;
 }