src/Algorithms.php
public function register($type, $class)
    {
        if (is_object($class)) {
            $class = get_class($class);
        }
        if (!is_string($class) || !class_exists($class)) {
            throw new \InvalidArgumentException();
        }
        if (!is_string($type) || !isset($this->algos[$type])) {
            throw new \InvalidArgumentException();
        }
        $name = $this->getValidAlgorithm($class);
        if ($name === null) {
            throw new \InvalidArgumentException();
        }

        $this->algos[$type][$name] = $class;
        uksort($this->algos[$type], array('self', 'sortAlgorithms'));
        return $this;
    }
public function register($type, $class)
    {
        if (is_object($class)) {
            $class = get_class($class);
        }
        if (!is_string($class) || !class_exists($class)) {
            throw new \InvalidArgumentException();
        }
        if (!is_string($type) || !isset($this->algos[$type])) {
            throw new \InvalidArgumentException();
        }
        $name = $this->getValidAlgorithm($class);
        if ($name === null) {
            throw new \InvalidArgumentException();
        }

        $this->algos[$type][$name] = $class;
        uksort($this->algos[$type], array('self', 'sortAlgorithms'));
        return $this;
    }
public function register ( $ type , $ class ) { if ( is_object ( $ class ) ) { $ class = get_class ( $ class ) ; } if ( ! is_string ( $ class ) || ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( ) ; } if ( ! is_string ( $ type ) || ! isset ( $ this -> algos [ $ type ] ) ) { throw new \ InvalidArgumentException ( ) ; } $ name = $ this -> getValidAlgorithm ( $ class ) ; if ( $ name === null ) { throw new \ InvalidArgumentException ( ) ; } $ this -> algos [ $ type ] [ $ name ] = $ class ; uksort ( $ this -> algos [ $ type ] , array ( 'self' , 'sortAlgorithms' ) ) ; return $ this ; }
Register a new algorithm.

\param string $type
Type of algorithm provided by the class.

\param string|object $class
Class or object that provides the algorithm.

\retval Algorithms
Returns the singleton.

\note
A class registered with this method will overwrite
any previously registered class with the same
algorithm name.
Register a new algorithm .