Passed
Push — master ( 5b3043...a2340d )
by butschster
09:28 queued 02:04
created

Verbosity::detect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Exceptions;
6
7
use Spiral\Boot\EnvironmentInterface;
8
use Spiral\Boot\Injector\InjectableEnumInterface;
9
use Spiral\Boot\Injector\ProvideFrom;
10
11
#[ProvideFrom(method: 'detect')]
12
enum Verbosity: int implements InjectableEnumInterface
13
{
14
    case BASIC = 0;
15
    case VERBOSE = 1;
16
    case DEBUG = 2;
17
18 40
    public static function detect(EnvironmentInterface $environment): self
19
    {
20 40
        return match (\strtolower((string) $environment->get('VERBOSITY_LEVEL'))) {
21 3
            'basic', '0' => self::BASIC,
22 2
            'debug', '2' => self::DEBUG,
23 40
            default => self::VERBOSE
24
        };
25
    }
26
}
27