HasFunctionCheck   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A check() 0 6 2
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