![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mcoil.corals.io/vendor/laravel/prompts/src/Concerns/ |
<?php namespace Laravel\Prompts\Concerns; use Closure; use RuntimeException; trait Fallback { /** * Whether to fallback to a custom implementation */ protected static bool $shouldFallback = false; /** * The fallback implementations. * * @var array<class-string, Closure($this): mixed> */ protected static array $fallbacks = []; /** * Enable the fallback implementation. */ public static function fallbackWhen(bool $condition): void { static::$shouldFallback = $condition || static::$shouldFallback; } /** * Whether the prompt should fallback to a custom implementation. */ public static function shouldFallback(): bool { return static::$shouldFallback && isset(static::$fallbacks[static::class]); } /** * Set the fallback implementation. * * @param Closure($this): mixed $fallback */ public static function fallbackUsing(Closure $fallback): void { static::$fallbacks[static::class] = $fallback; } /** * Call the registered fallback implementation. */ public function fallback(): mixed { $fallback = static::$fallbacks[static::class] ?? null; if ($fallback === null) { throw new RuntimeException('No fallback implementation registered for ['.static::class.']'); } return $fallback($this); } }