diff --git a/docs/documentation/selectors.md b/docs/documentation/selectors.md index c2fdc175..b1669079 100644 --- a/docs/documentation/selectors.md +++ b/docs/documentation/selectors.md @@ -34,6 +34,15 @@ The first selector will select all classes in the `App\User\Domain` namespace. The second one will select all classes in a namespace matching the regular expression. +## Selector::isError() +Select classes that extend the `\Error` class. + +## Selector::isException() +Select classes that extend the `\Exception` class. + +## Selector::isThrowable() +Select classes that implement the `\Throwable` interface. + ## Selector::implements() Select classes that implement the given interface. diff --git a/src/Selector/IsError.php b/src/Selector/IsError.php new file mode 100644 index 00000000..13539986 --- /dev/null +++ b/src/Selector/IsError.php @@ -0,0 +1,18 @@ +isSubclassOf(\Error::class); + } +} diff --git a/src/Selector/IsException.php b/src/Selector/IsException.php new file mode 100644 index 00000000..4802bfbc --- /dev/null +++ b/src/Selector/IsException.php @@ -0,0 +1,18 @@ +isSubclassOf(\Exception::class); + } +} diff --git a/src/Selector/IsThrowable.php b/src/Selector/IsThrowable.php new file mode 100644 index 00000000..107f57b4 --- /dev/null +++ b/src/Selector/IsThrowable.php @@ -0,0 +1,18 @@ +implementsInterface(\Throwable::class); + } +} diff --git a/src/Selector/SelectorPrimitive.php b/src/Selector/SelectorPrimitive.php index 62099ec3..b8d55766 100644 --- a/src/Selector/SelectorPrimitive.php +++ b/src/Selector/SelectorPrimitive.php @@ -9,6 +9,21 @@ public static function all(): All return new All(); } + public static function isException(): IsException + { + return new IsException(); + } + + public static function isThrowable(): IsThrowable + { + return new IsThrowable(); + } + + public static function isError(): IsError + { + return new IsError(); + } + /** * @deprecated * @see Selector::isInterface()