addConstant() 공개 메소드

Add Constant
public addConstant ( string $name, string | integer | null | float | array $value ) : self
$name string non-empty string
$value string | integer | null | float | array scalar
리턴 self
예제 #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);
             }
         }
     }
 }
예제 #2
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 = strtoupper($enum['value']);
             $value = strtoupper($enum['value']);
             if (!$class->hasConstant($name)) {
                 $class->addConstant($name, $value);
             }
         }
     }
 }