Horde_Kolab_Storage_Folder_Namespace::_getNamespace PHP Method

_getNamespace() private method

Get the namespace matching the given type and (optional) prefix.
private _getNamespace ( string $type, string $prefix = null ) : Horde_Kolab_Storage_Folder_Namespace_Element
$type string The namespace type.
$prefix string The namespace prefix
return Horde_Kolab_Storage_Folder_Namespace_Element The namespace.
    private function _getNamespace($type, $prefix = null)
    {
        $matching = array();
        foreach ($this->_namespaces as $namespace) {
            if ($namespace->getType() == $type && ($prefix === null || $namespace->getName() === $prefix)) {
                $matching[] = $namespace;
            }
        }
        if (count($matching) == 1) {
            return $matching[0];
        } else {
            if (count($matching) > 1) {
                throw new Horde_Kolab_Storage_Exception('Multiple namespaces of the same type!');
            } else {
                throw new Horde_Kolab_Storage_Exception(sprintf('No namespace of the type %s%s!', $type, $prefix !== null ? ' with prefix \\"' . $prefix . '\\"' : ''));
            }
        }
    }