Skip to content

Commit 13d627e

Browse files
committed
Определение запуска консольных команд.
1 parent 33988b8 commit 13d627e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Utils/ContextDetector.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Prokl\ServiceProvider\Utils;
4+
5+
/**
6+
* Class ContextDetector
7+
* @package Prokl\ServiceProvider\Utils
8+
*
9+
* @since 17.06.2021
10+
*/
11+
class ContextDetector
12+
{
13+
/**
14+
* Проверка - запускается консольная команда.
15+
*
16+
* @return boolean
17+
*/
18+
public static function isCli() : bool
19+
{
20+
if (PHP_BINARY && in_array(PHP_SAPI, ['cli', 'cli-server', 'phpdbg']) && is_file(PHP_BINARY)) {
21+
return true;
22+
}
23+
24+
return false;
25+
}
26+
}

0 commit comments

Comments
 (0)