| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Spatie\LaravelIgnition\Exceptions;
|
|
|
4 |
|
|
|
5 |
use Exception;
|
|
|
6 |
use Monolog\Logger;
|
|
|
7 |
use Spatie\Ignition\Contracts\BaseSolution;
|
|
|
8 |
use Spatie\Ignition\Contracts\ProvidesSolution;
|
|
|
9 |
use Spatie\Ignition\Contracts\Solution;
|
|
|
10 |
|
|
|
11 |
class InvalidConfig extends Exception implements ProvidesSolution
|
|
|
12 |
{
|
|
|
13 |
public static function invalidLogLevel(string $logLevel): self
|
|
|
14 |
{
|
|
|
15 |
return new self("Invalid log level `{$logLevel}` specified.");
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
public function getSolution(): Solution
|
|
|
19 |
{
|
|
|
20 |
$validLogLevels = array_map(
|
|
|
21 |
fn (string $level) => strtolower($level),
|
|
|
22 |
array_keys(Logger::getLevels())
|
|
|
23 |
);
|
|
|
24 |
|
|
|
25 |
$validLogLevelsString = implode(',', $validLogLevels);
|
|
|
26 |
|
|
|
27 |
return BaseSolution::create()
|
|
|
28 |
->setSolutionTitle('You provided an invalid log level')
|
|
|
29 |
->setSolutionDescription("Please change the log level in your `config/logging.php` file. Valid log levels are {$validLogLevelsString}.");
|
|
|
30 |
}
|
|
|
31 |
}
|