2012-01-20 18:10:48 +01:00
|
|
|
<?php
|
2015-09-10 23:13:48 +02:00
|
|
|
|
2017-01-04 23:16:12 +01:00
|
|
|
namespace SilverStripe\EnvironmentCheck\Checks;
|
|
|
|
|
|
|
|
use SilverStripe\EnvironmentCheck\EnvironmentCheck;
|
|
|
|
|
2012-01-20 18:10:48 +01:00
|
|
|
/**
|
|
|
|
* Check that the given function exists.
|
2017-01-04 23:16:12 +01:00
|
|
|
*
|
|
|
|
* @package environmentcheck
|
2012-01-20 18:10:48 +01:00
|
|
|
*/
|
2015-11-21 07:18:35 +01:00
|
|
|
class HasFunctionCheck implements EnvironmentCheck
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $functionName;
|
2015-09-10 23:13:48 +02:00
|
|
|
|
2015-11-21 07:18:35 +01:00
|
|
|
/**
|
|
|
|
* @param string $functionName The name of the function to look for.
|
|
|
|
*/
|
|
|
|
public function __construct($functionName)
|
|
|
|
{
|
|
|
|
$this->functionName = $functionName;
|
|
|
|
}
|
2015-09-10 23:13:48 +02:00
|
|
|
|
2015-11-21 07:18:35 +01:00
|
|
|
/**
|
2017-01-04 23:16:12 +01:00
|
|
|
* {@inheritDoc}
|
2015-11-21 07:18:35 +01:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function check()
|
|
|
|
{
|
2022-04-13 00:29:17 +02:00
|
|
|
if (function_exists($this->functionName ?? '')) {
|
2017-03-21 11:57:07 +01:00
|
|
|
return [EnvironmentCheck::OK, $this->functionName . '() exists'];
|
2015-11-21 07:18:35 +01:00
|
|
|
}
|
2017-03-21 11:57:07 +01:00
|
|
|
return [EnvironmentCheck::ERROR, $this->functionName . '() doesn\'t exist'];
|
2015-11-21 07:18:35 +01:00
|
|
|
}
|
2015-09-10 23:13:48 +02:00
|
|
|
}
|