|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Illuminate\Support\Facades; |
| 4 | + |
| 5 | +use Illuminate\Contracts\Debug\ExceptionHandler; |
| 6 | +use Illuminate\Support\Arr; |
| 7 | +use Illuminate\Support\Testing\Fakes\ExceptionHandlerFake; |
| 8 | + |
| 9 | +/** |
| 10 | + * @method static void register() |
| 11 | + * @method static \Illuminate\Foundation\Exceptions\ReportableHandler reportable(callable $reportUsing) |
| 12 | + * @method static \Illuminate\Foundation\Exceptions\Handler renderable(callable $renderUsing) |
| 13 | + * @method static \Illuminate\Foundation\Exceptions\Handler map(\Closure|string $from, \Closure|string|null $to = null) |
| 14 | + * @method static \Illuminate\Foundation\Exceptions\Handler dontReport(array|string $exceptions) |
| 15 | + * @method static \Illuminate\Foundation\Exceptions\Handler ignore(array|string $exceptions) |
| 16 | + * @method static \Illuminate\Foundation\Exceptions\Handler dontFlash(array|string $attributes) |
| 17 | + * @method static \Illuminate\Foundation\Exceptions\Handler level(string $type, void $level) |
| 18 | + * @method static void report(\Throwable $e) |
| 19 | + * @method static bool shouldReport(\Throwable $e) |
| 20 | + * @method static \Illuminate\Foundation\Exceptions\Handler throttleUsing(callable $throttleUsing) |
| 21 | + * @method static \Illuminate\Foundation\Exceptions\Handler stopIgnoring(array|string $exceptions) |
| 22 | + * @method static \Illuminate\Foundation\Exceptions\Handler buildContextUsing(\Closure $contextCallback) |
| 23 | + * @method static \Symfony\Component\HttpFoundation\Response render(\Illuminate\Http\Request $request, \Throwable $e) |
| 24 | + * @method static \Illuminate\Foundation\Exceptions\Handler respondUsing(callable $callback) |
| 25 | + * @method static \Illuminate\Foundation\Exceptions\Handler shouldRenderJsonWhen(callable $callback) |
| 26 | + * @method static \Illuminate\Foundation\Exceptions\Handler dontReportDuplicates() |
| 27 | + * @method static \Illuminate\Contracts\Debug\ExceptionHandler handler() |
| 28 | + * @method static void assertNothingReported() |
| 29 | + * @method static void assertReported(\Closure|string $exception) |
| 30 | + * @method static void assertReportedCount(int $count) |
| 31 | + * @method static void assertNotReported(\Closure|string $exception) |
| 32 | + * @method static void renderForConsole(\Symfony\Component\Console\Output\OutputInterface $output, \Throwable $e) |
| 33 | + * @method static \Illuminate\Support\Testing\Fakes\ExceptionHandlerFake throwFirstReported() |
| 34 | + * @method static \Illuminate\Support\Testing\Fakes\ExceptionHandlerFake setHandler(\Illuminate\Contracts\Debug\ExceptionHandler $handler) |
| 35 | + * |
| 36 | + * @see \Illuminate\Foundation\Exceptions\Handler |
| 37 | + * @see \Illuminate\Contracts\Debug\ExceptionHandler |
| 38 | + * @see \Illuminate\Support\Testing\Fakes\ExceptionHandlerFake |
| 39 | + */ |
| 40 | +class Exceptions extends Facade |
| 41 | +{ |
| 42 | + /** |
| 43 | + * Replace the bound instance with a fake. |
| 44 | + * |
| 45 | + * @param array<int, class-string<\Throwable>>|class-string<\Throwable> $exceptions |
| 46 | + * @return \Illuminate\Support\Testing\Fakes\ExceptionHandlerFake |
| 47 | + */ |
| 48 | + public static function fake(array|string $exceptions = []) |
| 49 | + { |
| 50 | + $exceptionHandler = static::isFake() |
| 51 | + ? static::getFacadeRoot()->handler() |
| 52 | + : static::getFacadeRoot(); |
| 53 | + |
| 54 | + return tap(new ExceptionHandlerFake($exceptionHandler, Arr::wrap($exceptions)), function ($fake) { |
| 55 | + static::swap($fake); |
| 56 | + }); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Get the registered name of the component. |
| 61 | + * |
| 62 | + * @return string |
| 63 | + */ |
| 64 | + protected static function getFacadeAccessor() |
| 65 | + { |
| 66 | + return ExceptionHandler::class; |
| 67 | + } |
| 68 | +} |
0 commit comments