mirror of
https://github.com/silverstripe/silverstripe-environmentcheck
synced 2024-06-28 15:39:47 +02:00
40 lines
818 B
PHP
40 lines
818 B
PHP
<?php
|
|
|
|
namespace SilverStripe\EnvironmentCheck\Checks;
|
|
|
|
use SilverStripe\EnvironmentCheck\EnvironmentCheck;
|
|
|
|
/**
|
|
* Check that the given class exists.
|
|
*
|
|
* @package environmentcheck
|
|
*/
|
|
class HasClassCheck implements EnvironmentCheck
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $className;
|
|
|
|
/**
|
|
* @param string $className The name of the class to look for.
|
|
*/
|
|
public function __construct($className)
|
|
{
|
|
$this->className = $className;
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*
|
|
* @return array
|
|
*/
|
|
public function check()
|
|
{
|
|
if (class_exists($this->className ?? '')) {
|
|
return [EnvironmentCheck::OK, 'Class ' . $this->className.' exists'];
|
|
}
|
|
return [EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist'];
|
|
}
|
|
}
|