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.
28 lines
678 B
28 lines
678 B
<?php |
|
|
|
namespace Facade\FlareClient\Context; |
|
|
|
class ContextContextDetector implements ContextDetectorInterface |
|
{ |
|
public function detectCurrentContext(): ContextInterface |
|
{ |
|
if ($this->runningInConsole()) { |
|
return new ConsoleContext($_SERVER['argv'] ?? []); |
|
} |
|
|
|
return new RequestContext(); |
|
} |
|
|
|
private function runningInConsole(): bool |
|
{ |
|
if (isset($_ENV['APP_RUNNING_IN_CONSOLE'])) { |
|
return $_ENV['APP_RUNNING_IN_CONSOLE'] === 'true'; |
|
} |
|
|
|
if (isset($_ENV['FLARE_FAKE_WEB_REQUEST'])) { |
|
return false; |
|
} |
|
|
|
return in_array(php_sapi_name(), ['cli', 'phpdb']); |
|
} |
|
}
|
|
|