* Filter links according to parameters.
*
* @param string $type Type of filter (eg. tags, permalink, etc.).
- * @param string $request Filter content.
+ * @param mixed $request Filter content.
* @param bool $casesensitive Optional: Perform case sensitive filter if true.
* @param bool $privateonly Optional: Only returns private links if true.
*
* @param string $smallHash permalink hash.
*
* @return array $filtered array containing permalink data.
+ *
+ * @throws LinkNotFoundException if the smallhash doesn't match any link.
*/
private function filterSmallHash($smallHash)
{
return $filtered;
}
}
+
+ if (empty($filtered)) {
+ throw new LinkNotFoundException();
+ }
+
return $filtered;
}
$tagsOut = $casesensitive ? $tags : mb_convert_case($tags, MB_CASE_LOWER, 'UTF-8');
$tagsOut = str_replace(',', ' ', $tagsOut);
- return array_filter(explode(' ', trim($tagsOut)), 'strlen');
+ return array_values(array_filter(explode(' ', trim($tagsOut)), 'strlen'));
}
}
+
+class LinkNotFoundException extends Exception
+{
+ protected $message = 'The link you are trying to reach does not exist or has been deleted.';
+}