Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ArgumentNullException | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
throwIfNull | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\Core\Throws; |
6 | |
7 | use Throwable; |
8 | use PeServer\Core\Throws\ArgumentException; |
9 | |
10 | class ArgumentNullException extends ArgumentException |
11 | { |
12 | use ThrowableTrait; |
13 | |
14 | #region function |
15 | |
16 | /** |
17 | * `null` の場合に `self` を投げる。 |
18 | * @param mixed $argument 評価対象。 |
19 | * @param string $name |
20 | * @throws ArgumentNullException |
21 | * @phpstan-assert !null $argument |
22 | */ |
23 | public static function throwIfNull(mixed $argument, string $name = ''): void |
24 | { |
25 | if ($argument === null) { |
26 | throw new ArgumentNullException($name); |
27 | } |
28 | } |
29 | |
30 | #endregion |
31 | } |