<?php
namespace ThurData\Servers\KerioEmail\App\Libs\Restrictions\Rules;
use ThurData\Servers\KerioEmail\App\Libs\Restrictions\Interfaces\AbstractRule;

/**
 *
 * Created by PhpStorm.
 * User: ThurData
 * Date: 07.11.19
 * Time: 09:58
 * Class ExtensionsValid
 */
class ExtensionsValid extends AbstractRule
{

    const EXTENSIONS = [
        'soap' => \SoapClient::class
    ];

    /**
     * @var string
     */
    protected $message = 'extensionRequired';

    /**
     * check if rule is valid
     * @return mixed
     */
    public function isValid()
    {
        foreach (self::EXTENSIONS as $extension => $class)
        {
            if(!class_exists($class))
            {
                $this->addReplacement('extension', $extension);
                return false;
            }
        }

        return true;
    }
}