Debug::cli()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * Copyright (c) 2020.
4
 * @author Paweł Antosiak <[email protected]>
5
 */
6
7
declare(strict_types=1);
8
9
namespace Gorynych\Util;
10
11
use Whoops\Handler\HandlerInterface;
12
use Whoops\Handler\PlainTextHandler;
13
use Whoops\Handler\PrettyPageHandler;
14
use Whoops\Run;
15
16
final class Debug
17
{
18
    /**
19
     * Enables debug mode for web environment (only for non-production)
20
     *
21
     * @param HandlerInterface|null $handler custom error handler
22
     */
23
    public static function web(HandlerInterface $handler = null): void
24
    {
25
        if ('prod' === EnvAccess::get('APP_ENV', 'dev')) {
26
            error_reporting(0);
27
            ini_set('display_errors', '0');
28
29
            return;
30
        }
31
32
        (new Run())->pushHandler($handler ?? new PrettyPageHandler())->register();
33
    }
34
35
    /**
36
     * Enables debug mode for CLI environment
37
     */
38
    public static function cli(): void
39
    {
40
        (new Run())->pushHandler(new PlainTextHandler())->register();
41
    }
42
}
43