PHP Classes

File: src/Exceptions/src/Verbosity.php

Recommend this page to a friend!
  Packages of Wolfy-J   spiral   src/Exceptions/src/Verbosity.php   Download  
File: src/Exceptions/src/Verbosity.php
Role: Example script
Content type: text/plain
Description: Example script
Class: spiral
Modular Web application development framework
Author: By
Last change:
Date: 11 months ago
Size: 647 bytes
 

 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace Spiral\Exceptions;

use Spiral\Boot\EnvironmentInterface;
use Spiral\Boot\Injector\InjectableEnumInterface;
use Spiral\Boot\Injector\ProvideFrom;

#[ProvideFrom(method: 'detect')]
enum Verbosity: int implements InjectableEnumInterface
{
    case BASIC = 0;
    case VERBOSE = 1;
    case DEBUG = 2;

    public static function detect(EnvironmentInterface $environment): self
    {
        return match (\strtolower((string) $environment->get('VERBOSITY_LEVEL'))) {
            'basic', '0' => self::BASIC,
            'debug', '2' => self::DEBUG,
            default => self::VERBOSE,
        };
    }
}