Passed
Pull Request — master (#838)
by Georges
04:11 queued 02:01
created

SapiDetector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 13
rs 10
c 1
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isCliScript() 0 3 2
A isWebScript() 0 3 3
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