diff --git a/lib/Nag.php b/lib/Nag.php index b696f46..9e1c446 100644 --- a/lib/Nag.php +++ b/lib/Nag.php @@ -109,6 +109,24 @@ class Nag */ public const VIEW_FUTURE_INCOMPLETE = 4; + /** + * Returns whether a value is a Nag::VIEW_* task list filter. + * + * @param mixed $filter Tab name or show_completed value. + * + * @return bool + */ + public static function isTaskViewFilter($filter): bool + { + if (!is_int($filter) && !(is_string($filter) && $filter !== '' && ctype_digit($filter))) { + return false; + } + + $filter = (int) $filter; + + return $filter >= self::VIEW_INCOMPLETE && $filter <= self::VIEW_FUTURE_INCOMPLETE; + } + /** * WebDAV task list. */