$path ){ // path should be normalized absolute path and be compared only with others of the same $path = Loco_fs_File::abs($path); if( ! $path ){ throw new InvalidArgumentException('Location must be absolute path'); } // path must have trailing slash, otherwise "/plugins/foobar" would match "/plugins/foo/" $path = trailingslashit($path); $cache[$path] = strlen($path); } parent::__construct( $cache ); } /** * Check if a given path begins with any of the registered ones * @param string absolute path * @return bool whether path matched */ public function check( $path ){ $path = Loco_fs_File::abs($path); foreach( $this as $prefix => $length ){ if( substr($path,0,$length) === $prefix ){ return true; } } return false; } }