Completed
Push — master ( 8dce14...ef59ee )
by Freek
13:50
created

InvalidConfig::getSolution()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace Facade\Ignition\Exceptions;
4
5
use Exception;
6
use Monolog\Logger;
7
use Facade\IgnitionContracts\Solution;
8
use Facade\IgnitionContracts\BaseSolution;
9
use Facade\IgnitionContracts\ProvidesSolution;
10
11
class InvalidConfig extends Exception implements ProvidesSolution
12
{
13
    public static function invalidLogLevel(string $logLevel)
14
    {
15
        return new static("Invalid log level `{$logLevel}` specified.");
16
    }
17
18
    public function getSolution(): Solution
19
    {
20
        $validLogLevels = array_map(function (string $level) {
21
            return strtolower($level);
22
        }, array_keys(Logger::getLevels()));
23
24
        $validLogLevelsString = implode(',', $validLogLevels);
25
26
        return BaseSolution::create('You provided an invalid log level')
27
            ->setSolutionDescription("Please change the log level in your `config/logging.php` file. Valid log levels are {$validLogLevelsString}.");
28
    }
29
}
30