1. Go to this page and download the library: Download aurimasniekis/throws library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aurimasniekis / throws example snippets
use function Throws\thr;
thr(new Exception("FooBar"));
use function Throws\thrException;
thrException('Oh now "%s" error occurred', 'Big Error');
// Instead of this
if ($foo !== 'bar') {
throw new InvalidArgumentException(
sprintf(
'Oh no $foo is "%s"',
$foo
)
);
}
// Much simpler
$foo !== 'bar' || thrInvalidArgumentException('Oh no $foo is "%s"', $foo);
// Instead of this
if (false === isset($array['key'])) {
throw new InvalidArgumentException('Oh no key is missing');
}
// Much simpler
$array['key'] ?? thrInvalidArgumentException('Oh no key is missing');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.