Issues (37)

demo/demo.standwithukraine-splash-screen.php (1 issue)

1
<?php
2
require_once __DIR__ .'/../vendor/autoload.php';
3
use Kristuff\Mishell\Console;  
4
5
// *open* new window
6
Console::newWindow();
7
8
declare(ticks = 1);                                      // Allow posix signal handling
9
pcntl_async_signals(true);
10
pcntl_signal(SIGINT,"shutdown");       
11
register_shutdown_function("shutdown");                 // Handle END of script
12
13
splash();
14
15
function shutdown(){
16
    //     echo "\033c";                                        // Clear terminal
17
    //     echo PHP_EOL;                                        // New line
18
    //Console::log();
19
    //Console::log('SIGINT signal detected, terminate script...');
20
    //system("tput cnorm && tput cup 0 0 && stty echo");   // Restore cursor default
21
    usleep(115000);
22
    Console::restoreWindow();
23
    exit(0);
0 ignored issues
show
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...
24
}
25
26
function splash()
27
{
28
29
    // get columns / lines and calculate middle
30
    $lines  = Console::getLines();
31
    $cols   = Console::getColumns();
32
    $middle = round($lines/2);
33
34
    for ($i= 1; $i <= $lines ; $i++){
35
        switch($i){
36
            case $middle -1:    Console::log(Console::pad("Stand With Ukraine <3", $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue');    break;
37
            case $middle:       Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue');                        break;
38
            case $middle +1:    Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow');                        break;
39
            case $middle +2:    Console::log(Console::pad('Slava Ukraini', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow');            break;
40
            case $lines:        Console::print(Console::pad(' Wait a few seconds or hint Ctrl+C', $cols , ' ', STR_PAD_LEFT), 'blue', 'yellow');  break; // no new line here
41
            default:
42
                if ($i > $middle) {
43
                    Console::log(Console::pad(' ', $cols), 'blue', 'yellow');
44
                } else {
45
                    Console::log(Console::pad(' ', $cols), 'yellow', 'blue');
46
                }
47
        }
48
    }
49
50
    sleep(6);
51
52
    // restore previous window
53
    Console::restoreWindow();
54
55
}
56
57
58
?>
59