public function add(AbstractSymbol $symbol, $replaceSymbol = null)
    {
        if (sizeof($symbol->getIdentifiers()) == 0) {
            throw new \LengthException('Error: AbstractSymbol does not have any identifiers');
        }

        if ($replaceSymbol === null) {
            if (array_key_exists(get_class($symbol), $this->symbols)) {
                throw new \InvalidArgumentException(
                    'Error: Trying to replace a symbol without using $replaceClass parameter'
                );
            }

            $this->symbols[] = $symbol;
        } else {
            if (! is_string($replaceSymbol)) {
                throw new \InvalidArgumentException('Error: $replaceClass has to be the name of a class');
            }

            if (! array_key_exists($replaceSymbol, $this->symbols)) {
                throw new \InvalidArgumentException('Error: Cannot replace the specified class since it is not known');
            }

            $this->symbols[$replaceSymbol] = $symbol;
        }

        $this->validate();
    }