PHP Classes

File: src/Boot/src/Environment/DebugMode.php

Recommend this page to a friend!
  Packages of Wolfy-J   spiral   src/Boot/src/Environment/DebugMode.php   Download  
File: src/Boot/src/Environment/DebugMode.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: 611 bytes
 

 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace Spiral\Boot\Environment;

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

#[ProvideFrom(method: 'detect')]
enum DebugMode implements InjectableEnumInterface
{
    case Enabled;
    case Disabled;

    public static function detect(EnvironmentInterface $environment): self
    {
        return \filter_var($environment->get('DEBUG'), \FILTER_VALIDATE_BOOL) ? self::Enabled : self::Disabled;
    }

    public function isEnabled(): bool
    {
        return $this === self::Enabled;
    }
}