You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
821 B
47 lines
821 B
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* @author Robert Strutts <Robert@TryingToScale.com>
|
|
* @copyright Copyright (c) 2022, Robert Strutts.
|
|
* @license MIT
|
|
*/
|
|
|
|
namespace CodeHydrater;
|
|
|
|
final class consoleApp {
|
|
public static $is_cli = false;
|
|
|
|
public static function is_cli() {
|
|
if (static::$is_cli) {
|
|
return true;
|
|
}
|
|
|
|
if (defined('STDIN')) {
|
|
return true;
|
|
}
|
|
|
|
if (php_sapi_name() === 'cli') {
|
|
return true;
|
|
}
|
|
|
|
if (array_key_exists('SHELL', $_ENV)) {
|
|
return true;
|
|
}
|
|
|
|
// $argv = $_SERVER['argv'] ?? [];
|
|
// && count($argv) > 0
|
|
|
|
if (!isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['HTTP_USER_AGENT'])) {
|
|
return true;
|
|
}
|
|
|
|
if (!array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|