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();
    }
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();
    }
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 ( ) ; }
Adds a symbol to the array of symbols. This method allows to add symbols
at runtime from the outside of this library.

@param AbstractSymbol $symbol        The new symbol object
@param string|null    $replaceSymbol Class name of an known symbol that you want to replace
@return void
@throws \InvalidArgumentException
Adds a symbol to the array of symbols . This method allows to add symbols at runtime from the outside of this library .