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;
    }