HEX
Server: Apache/2
System: Linux server-27-254-144-72.da.direct 5.10.0-33-amd64 #1 SMP Debian 5.10.226-1 (2024-10-03) x86_64
User: pokaorgani (1114)
PHP: 8.1.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/pokaorgani/public_html/wp-content/plugins/gallery-by-supsystic/vendor/Rsc/Form/Rule/Regex.php
<?php


class RscSgg_Form_Rule_Regex implements RscSgg_Form_Rule_Interface
{

    /**
     * @var string
     */
    public $label;

    /**
     * @var string
     */
    public $parameters;

    /**
     * @var string
     */
    public $message;

    /**
     * Constructor
     * @param string $label Field label
     * @param string $parameters Rule parameters
     * @throws InvalidArgumentException
     */
    function __construct($label, $parameters = null)
    {
        $this->label = $label;

        if (!is_string($parameters)) {
            throw new InvalidArgumentException(sprintf('Parameter of form rule Regex must be a string, %s given', gettype($parameters)));
        }

        $this->parameters = $parameters;
    }

    /**
     * Validate specified field
     * @param mixed $field Field data
     * @return bool
     */
    function validate($field)
    {
        return (preg_match($this->parameters, $field));
    }

    /**
     * Returns rule error message
     * @return string
     */
    function getMessage()
    {
        if ($this->message !== null) {
            return sprintf($this->message, $this->label);
        }

        return sprintf(__('The %s field does not match with regex', 'rsc-framework'), $this->label);
    }

    /**
     * Sets the error message
     * @param string $message Error message
     * @return RscSgg_Form_Rule_Regex
     */
    public function setMessage($message)
    {
        $this->message = $message;

        return $this;
    }

    /**
     * Creates the new instance
     * @param string $label Field label
     * @param string $parameters Rule parameters
     * @return RscSgg_Form_Rule_Regex
     */
    public static function create($label, $parameters)
    {
        return new self($label, $parameters);
    }
}