Passed
Pull Request — master (#838)
by Georges
03:44 queued 01:36
created

SapiDetector::isWebScript()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 1
nc 3
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 *
4
 * This file is part of Phpfastcache.
5
 *
6
 * @license MIT License (MIT)
7
 *
8
 * For full copyright and license information, please see the docs/CREDITS.txt and LICENCE files.
9
 *
10
 * @author Georges.L (Geolim4)  <[email protected]>
11
 * @author Contributors  https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors
12
 */
13
14
declare(strict_types=1);
15
16
namespace Phpfastcache\Util;
17
18
class SapiDetector
19
{
20
    /**
21
     * @SuppressWarnings(PHPMD.Superglobals)
22
     */
23
    public static function isWebScript(): bool
24
    {
25
        return \PHP_SAPI === 'apache2handler' || str_contains(\PHP_SAPI, 'handler') || isset($_SERVER['REQUEST_METHOD']);
26
    }
27
28
    public static function isCliScript(): bool
29
    {
30
        return (\PHP_SAPI === 'cli') || \defined('STDIN');
31
    }
32
}
33