Concerns
1 year ago
Contracts
1 year ago
ComplexConditionSet.php
1 year ago
Config.php
1 year ago
FieldCondition.php
1 year ago
NestedCondition.php
1 year ago
SimpleConditionSet.php
1 year ago
Config.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Give\Vendors\StellarWP\FieldConditions; |
| 6 | |
| 7 | use InvalidArgumentException; |
| 8 | |
| 9 | /** |
| 10 | * Sets up the Field Condition library. It currently only provides an optional means of replacing an exception. |
| 11 | * |
| 12 | * @since 1.0.0 |
| 13 | */ |
| 14 | class Config |
| 15 | { |
| 16 | /** |
| 17 | * @var class-string<InvalidArgumentException> |
| 18 | */ |
| 19 | private static $invalidArgumentExceptionClass = InvalidArgumentException::class; |
| 20 | |
| 21 | /** |
| 22 | * @since 1.0.0 |
| 23 | * |
| 24 | * @throws InvalidArgumentException |
| 25 | */ |
| 26 | public static function throwInvalidArgumentException() |
| 27 | { |
| 28 | throw new self::$invalidArgumentExceptionClass(...func_get_args()); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * @since 1.0.0 |
| 33 | * |
| 34 | * @return class-string<InvalidArgumentException> |
| 35 | */ |
| 36 | public static function getInvalidArgumentExceptionClass(): string |
| 37 | { |
| 38 | return self::$invalidArgumentExceptionClass; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @since 1.0.0 |
| 43 | * |
| 44 | * @param class-string<InvalidArgumentException> $invalidArgumentExceptionClass |
| 45 | */ |
| 46 | public static function setInvalidArgumentExceptionClass(string $invalidArgumentExceptionClass) |
| 47 | { |
| 48 | if (!is_a($invalidArgumentExceptionClass, InvalidArgumentException::class, true)) { |
| 49 | throw new RuntimeException( |
| 50 | 'The invalid argument exception class must extend the InvalidArgumentException' |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | self::$invalidArgumentExceptionClass = $invalidArgumentExceptionClass; |
| 55 | } |
| 56 | } |
| 57 |