ComposerDependenciesCheck.php in CloudFlare 8
File
src/ComposerDependenciesCheck.php
View source
<?php
namespace Drupal\cloudflare;
use Psr\Log\LoggerInterface;
use Drupal\cloudflare\Exception\ComposerDependencyException;
class ComposerDependenciesCheck implements CloudFlareComposerDependenciesCheckInterface {
public static $areDependenciesMet = NULL;
protected $logger;
public static function create(LoggerInterface $logger) {
return new static($logger);
}
public function __construct(LoggerInterface $logger) {
$this->logger = $logger;
}
public function check() {
if (!is_null(self::$areDependenciesMet)) {
return self::$areDependenciesMet;
}
if (class_exists('\\CloudFlarePhpSdk\\ApiEndpoints\\ZoneApi')) {
self::$areDependenciesMet = TRUE;
}
else {
self::$areDependenciesMet = FALSE;
$this->logger
->critical(self::ERROR_MESSAGE);
}
return self::$areDependenciesMet;
}
public function assert() {
if (!$this
->check()) {
throw new ComposerDependencyException(self::ERROR_MESSAGE);
}
}
}