You are here

abstract class SupportedPhpVersion in Automatic Updates 8

Supported PHP version checker.

Hierarchy

Expanded class hierarchy of SupportedPhpVersion

File

src/ReadinessChecker/SupportedPhpVersion.php, line 10

Namespace

Drupal\automatic_updates\ReadinessChecker
View source
abstract class SupportedPhpVersion implements ReadinessCheckerInterface {

  /**
   * {@inheritdoc}
   */
  public function run() {
    $messages = [];
    $parser = new VersionParser();
    $unsupported_constraint = $this
      ->getUnsupportedVersionConstraint();
    if ($unsupported_constraint
      ->matches($parser
      ->parseConstraints($this
      ->getPhpVersion()))) {
      $messages[] = $this
        ->getMessage();
    }
    return $messages;
  }

  /**
   * Get the PHP version.
   *
   * @return string
   *   The current php version.
   */
  protected function getPhpVersion() {
    return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  }

  /**
   * Get the unsupported PHP version constraint.
   *
   * @return \Composer\Semver\Constraint\ConstraintInterface
   *   The version constraint.
   */
  protected abstract function getUnsupportedVersionConstraint();

  /**
   * Get the message to return if the current PHP version is unsupported.
   *
   * @return \Drupal\Component\Render\MarkupInterface
   *   The message to return if the current PHP version is unsupported.
   */
  protected abstract function getMessage();

}

Members

Namesort descending Modifiers Type Description Overrides
SupportedPhpVersion::getMessage abstract protected function Get the message to return if the current PHP version is unsupported. 2
SupportedPhpVersion::getPhpVersion protected function Get the PHP version. 2
SupportedPhpVersion::getUnsupportedVersionConstraint abstract protected function Get the unsupported PHP version constraint. 2
SupportedPhpVersion::run public function Run check. Overrides ReadinessCheckerInterface::run