1<?php
2
3
4namespace ComboStrap;
5
6
7class Console
8{
9
10
11    /**
12     * Print to the console even if OB (Output buffer) is used
13     * @param $message
14     */
15    public static function log($message)
16    {
17        $consoleOn = ExecutionContext::getActualOrCreateFromEnv()->isConsoleOn();
18        if ($consoleOn) {
19            fputs(STDOUT, "Console Info: " . $message . PHP_EOL);
20        }
21    }
22
23    /**
24     * @deprecated for {@link ExecutionContext::setConsoleOff()}
25     * @return void
26     */
27    public static function setOff()
28    {
29        ExecutionContext::getActualOrCreateFromEnv()->setConsoleOff();
30    }
31
32    /**
33     * @deprecated for {@link ExecutionContext::setConsoleOn()}
34     * @return void
35     */
36    public static function setOn()
37    {
38        ExecutionContext::getActualOrCreateFromEnv()->setConsoleOn();
39    }
40
41    public static function isConsoleRun(): bool
42    {
43        return (php_sapi_name() === 'cli');
44    }
45
46}
47