public function addConstant($name, $value, $overrideOnDefined = false)
    {
        if ($this->classConstants->offsetExists($name) === true) {
            if ($overrideOnDefined === false) {
                throw Exception\ClassFile::constantAlreadyDefined($this->className, $name);
            }

            $this->classConstants->offsetUnset($name);
        }

        if (
            PHPUtils::isReservedAny($name) === true ||
            (((bool) preg_match('/^[^a-zA-Z_]/', $name)) === true)
        ) {
            throw Exception\ClassFile::invalidConstantName($this->className, $name);
        }

        $classConstant = new Element\ClassConstant($name, $value);
        $this->classConstants->offsetSet($name, $classConstant);

        return $classConstant;
    }