Zend\Code\Generator\ClassGenerator::hasConstant PHP Method

hasConstant() public method

public hasConstant ( string $constantName ) : boolean
$constantName string
return boolean
    public function hasConstant($constantName)
    {
        return isset($this->constants[$constantName]);
    }

Usage Example

Example #1
0
 protected function handleEnumeration(Generator\ClassGenerator $class, PHPClass $type)
 {
     if ($type->getChecks('__value') && isset($type->getChecks('__value')['enumeration'])) {
         $enums = $type->getChecks('__value')['enumeration'];
         foreach ($enums as $enum) {
             $name = $enum['value'];
             $name = preg_replace("~([a-z])([A-Z])~", "\$1_\$2", $name);
             $name = preg_replace("~([a-z])([0-9])~", "\$1_\$2", $name);
             $name = strtoupper($name);
             $name = str_replace(':', '_', $name);
             switch ($name) {
                 case "DEFAULT":
                 case "PRIVATE":
                 case "EMPTY":
                     $name .= "_CONSTANT";
                     break;
             }
             $value = $enum['value'];
             if (!$class->hasConstant($name)) {
                 $class->addConstant($name, $value);
             }
         }
     }
 }
All Usage Examples Of Zend\Code\Generator\ClassGenerator::hasConstant