/** * Checks whether the given path ($path) is available in the hash. * @param $path A list of keys to traverse, seperated by '/' * @param $hash The hash to search * @return bool */ public static function exists($path, $hash) { $path = \arc\path::collapse($path); $parent = \arc\path::parent($path); $filename = basename($path); $hash = self::get($parent, $hash); return is_array($hash) && array_key_exists($filename, $hash); }
function testParent() { $this->assertTrue(\arc\path::parent('/') == null); $this->assertTrue(\arc\path::parent('/test/') == '/'); $this->assertTrue(\arc\path::parent('/a/b/') == '/a/'); $this->assertTrue(\arc\path::parent('/a/b/', '/a/b/') == null); $this->assertTrue(\arc\path::parent('/a/b/', '/a/') == '/a/'); $this->assertTrue(\arc\path::parent('/a/b/', '/test/') == null); }