Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Console
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
6
100.00% covered (success)
100.00%
1 / 1
 header
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
5
 footer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * Pop PHP Framework (http://www.popphp.org/)
4 *
5 * @link       https://github.com/popphp/pop-bootstrap
6 * @author     Nick Sagona, III <nick@nolainteractive.com>
7 * @copyright  Copyright (c) 2012-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)
8 * @license    http://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Kettle\Event;
15
16use Pop\App;
17use Pop\Kettle\Model\Application;
18
19/**
20 * Console event class
21 *
22 * @category   Pop\Kettle
23 * @package    Pop\Kettle
24 * @author     Nick Sagona, III <dev@nolainteractive.com>
25 * @copyright  Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)
26 * @license    http://www.popphp.org/license     New BSD License
27 * @version    2.3.2
28 */
29class Console
30{
31
32    /**
33     * Production check omit commands
34     * @var array
35     */
36    protected static array $omitCommands = ['app:env', 'app:status', 'help', 'version'];
37
38    /**
39     * Display console header
40     *
41     * @return void
42     */
43    public static function header(): void
44    {
45        $console     = new \Pop\Console\Console();
46        $routeString = App::get()->router()->getRouteMatch()->getRouteString();
47
48        echo PHP_EOL . $console->header('Pop Kettle', '=', null, 'left', true, true) . PHP_EOL;
49
50        if (App::isDown() && ($routeString != 'app:up')) {
51            $console->alertInfo('Application in Maintenance', 40);
52        }
53
54        if ((App::isProduction()) && !in_array($routeString, self::$omitCommands)) {
55            $console->alertWarning('Application in Production', 40);
56            $console->confirm('Are you sure you want to run this command?');
57        }
58    }
59
60    /**
61     * Display console footer
62     *
63     * @return void
64     */
65    public static function footer(): void
66    {
67        echo PHP_EOL;
68    }
69
70}