HasFunctionCheck::check()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\EnvironmentCheck\Checks;
4
5
use SilverStripe\EnvironmentCheck\EnvironmentCheck;
6
7
/**
8
 * Check that the given function exists.
9
 *
10
 * @package environmentcheck
11
 */
12
class HasFunctionCheck implements EnvironmentCheck
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $functionName;
18
19
    /**
20
     * @param string $functionName The name of the function to look for.
21
     */
22
    public function __construct($functionName)
23
    {
24
        $this->functionName = $functionName;
25
    }
26
27
    /**
28
     * {@inheritDoc}
29
     *
30
     * @return array
31
     */
32
    public function check()
33
    {
34
        if (function_exists($this->functionName)) {
35
            return [EnvironmentCheck::OK, $this->functionName . '() exists'];
36
        }
37
        return [EnvironmentCheck::ERROR, $this->functionName . '() doesn\'t exist'];
38
    }
39
}
40