public static function factory(string $name, $options = null): RepositoryInterface
    {
        try {
            $className = sprintf(
                '%s\%sRepository',
                self::getNamespace(),
                ucfirst(strtolower($name))
            );
            $reflectionClass = new \ReflectionClass($className);
            if (is_null($options)) {
                return $reflectionClass->newInstance();
            }
            return $reflectionClass->newInstance($options);
        } catch (\ReflectionException $ex) {
            throw new InvalidRepositoryException(
                sprintf('The %s repository does not exist.', $name)
            );
        }
    }