public function setFactory($iface, $cls)
    {
        $ifaceName = self::normalizeInterface($iface);

        if (!class_exists($cls, true)) {
            throw new \Erebot\InvalidValueException('No such class ('.$cls.')');
        }

        $reflector = new \ReflectionClass($cls);
        if (!$reflector->isSubclassOf($ifaceName)) {
            throw new \Erebot\InvalidValueException(
                'A class that implements the interface was expected'
            );
        }
        $this->factories[$ifaceName] = $cls;
    }