Passed
Push — master ( 91f02d...65071d )
by Melech
21:33 queued 07:21
created

Exiter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
dl 0
loc 26
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A freeze() 0 3 1
A unfreeze() 0 3 1
A exit() 0 3 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Valkyrja\Support;
15
16
/**
17
 * Class Exiter.
18
 *
19
 * @author Melech Mizrachi
20
 */
21
class Exiter
22
{
23
    protected static bool $exit = true;
24
25
    /**
26
     * Freeze the exiter.
27
     */
28
    public static function freeze(): void
29
    {
30
        static::$exit = false;
31
    }
32
33
    /**
34
     * Unfreeze the exiter.
35
     */
36
    public static function unfreeze(): void
37
    {
38
        static::$exit = true;
39
    }
40
41
    /**
42
     * Exit, or don't. Up to you :).
43
     */
44
    public static function exit(int $code = 0): void
45
    {
46
        static::$exit ? exit($code) : '';
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
47
    }
48
}
49