kaida-by / php-multiexception
Catch a few exceptions and show them
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/kaida-by/php-multiexception
Requires
- php: >=7.0.0
This package is auto-updated.
Last update: 2025-12-29 03:54:19 UTC
README
use KaidaBy\MultiException; function checkSomethingString($string): bool { $exceptions = new MultiException(); if (mb_strlen($string) < 6) { $exceptions->add(new Exception('The string must be longer than 6 characters')); } if (!is_string($string)) { $exceptions->add(new Exception('The input parameter should be a string')); } if (preg_match('%^\p{Lu}%u', $string)) { $exceptions->add(new Exception('The line must begin with a capital letter.')); } if (!$exceptions->isEmpty()) { throw $exceptions; } return true; } try { checkSomething($thing); } catch (MultiException $exceptions) { foreach ($exceptions as $exception) { echo $exception->getMessage() . PHP_EOL; } }