/**
* Implements the loading of the class object
*
* @throws Exception if the class is already generated(not null)
*/
protected function generateClass()
{
if ($this->class != null) {
throw new Exception("The class has already been generated");
}
$this->class = new PhpClass($this->phpIdentifier, false);
$first = true;
$names = array();
foreach ($this->values as $value) {
$name = Validator::validateConstant($value);
$name = Validator::validateUnique($name, function ($name) use($names) {
return !in_array($name, $names);
});
if ($first) {
$this->class->addConstant($name, '__default');
$first = false;
}
$this->class->addConstant($value, $name);
$names[] = $name;
}
}