HEX
Server: Apache
System: Linux webm004.cluster121.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
User: grainesdfo (155059)
PHP: 5.4.45
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/grainesdfo/www/wp-content/plugins/backwpup/inc/Notice/EnvironmentNotice.php
<?php

namespace Inpsyde\BackWPup\Notice;

use Inpsyde\EnvironmentChecker\Constraints\AbstractVersionConstraint;
use Inpsyde\EnvironmentChecker\EnvironmentChecker;
use Inpsyde\EnvironmentChecker\Exception\ConstraintFailedExceptionInterface;

abstract class EnvironmentNotice extends Notice
{
    /**
     * {@inheritdoc}
     */
    protected function render(NoticeMessage $message): void
    {
        $this->view->warning($message, $this->getDismissActionUrl());
    }

    /**
     * {@inheritdoc}
     */
    protected function isScreenAllowed(): bool
    {
        return true;
    }

    /**
     * {@inheritdoc}
     */
    protected function shouldDisplay(): bool
    {
        if (parent::shouldDisplay()) {
            $checker = new EnvironmentChecker($this->getConstraints());

            try {
                $checker->check();

                // Passed constraints, so do not display
                return false;
            } catch (ConstraintFailedExceptionInterface|\RuntimeException $e) {
                return true;
            }
        }

        return false;
    }

    /**
     * Returns list of constraints to check.
     *
     * @return AbstractVersionConstraint[] The list of constraints
     */
    abstract protected function getConstraints(): array;
}