Util   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A is_running_test() 0 6 2
1
<?php
2
3
/**
4
 * @author  Russell Michell 2018 <[email protected]>
5
 * @package silverstripe-verifiable
6
 */
7
8
namespace PhpTek\Verifiable\Util;
9
10
use SilverStripe\Dev\Backtrace;
11
use SilverStripe\Control\Director;
12
13
/**
14
 * Some utility routines.
15
 */
16
class Util
17
{
18
    /**
19
     * Is the current request, one from a the test runner?
20
     *
21
     * @return bool
22
     * @todo   Use this as the basis of Injector-backed stubbing
23
     */
24
    public static function is_running_test() : bool
25
    {
26
        $trace = Backtrace::backtrace(true, true);
27
28
        // Test for CLI SAPI first, so we don't waste time during legit TTW writes
29
        return Director::is_cli() && stristr($trace, 'PHPUnit') !== false;
30
    }
31
}
32