| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- namespace ThurData\Servers\KerioEmail\App\Libs\Restrictions\Interfaces;
- use ThurData\Servers\KerioEmail\App\Libs\Restrictions\Restriction;
- /**
- *
- * Created by PhpStorm.
- * User: ThurData
- * Date: 07.11.19
- * Time: 10:29
- * Class AbstractRestriction
- */
- abstract class AbstractRestriction
- {
- const STATUS_VALID = true;
- const STATUS_INVALID = false;
- /**
- * @var bool
- */
- protected $throwError = false;
- /**
- * @var RuleInterface
- */
- protected $rule;
- /**
- * @var
- */
- public $errorMessage;
- /**
- * @var bool
- */
- public $isValid = self::STATUS_VALID;
- /**
- * Restriction constructor.
- * @param RuleInterface $rule
- */
- public function __construct(RuleInterface $rule)
- {
- $this->rule = $rule;
- }
- /**
- *
- * check restriction
- * @return mixed
- */
- public abstract function check();
- /**
- * @return bool
- */
- public function isThrowErrorEnabled()
- {
- return $this->throwError === true;
- }
- /**
- * @return $this
- */
- public function enableThrowError()
- {
- $this->throwError = true;
- return $this;
- }
- /**
- * @return $this
- */
- public function disableThrowError()
- {
- $this->throwError = true;
- return $this;
- }
- /**
- * @return RuleInterface
- */
- public function getRule()
- {
- return $this->rule;
- }
- /**
- * @param RuleInterface $rule
- */
- public function setRule(RuleInterface $rule)
- {
- $this->rule = $rule;
- }
- /**
- * @return mixed
- */
- public function getErrorMessage()
- {
- return $this->errorMessage;
- }
- /**
- * @param mixed $errorMessage
- */
- public function setErrorMessage($errorMessage)
- {
- $this->errorMessage = $errorMessage;
- }
- /**
- * @return bool
- */
- public function isValid()
- {
- return $this->isValid;
- }
- /**
- * @param bool $isValid
- */
- public function setIsValid($isValid)
- {
- $this->isValid = $isValid;
- }
- }
|