protected function detectNamespace($settings)
    {
        foreach ($this->options->getNamespaces() as $namespaceOptions) {
            $namespaceEntityClass = $namespaceOptions->getEntityClass();
            if ($settings instanceof $namespaceEntityClass) {
                return $namespaceOptions->getName();
            }
        }

        throw new Exception\InvalidArgumentException('Unknown Settings namespace');
    }