for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by PhpStorm.
* User: harry
* Date: 2/15/18
* Time: 5:05 PM
*/
namespace PluginSimpleValidate;
use PluginSimpleValidate\Libraries\Language;
class Rule implements \PluginSimpleValidate\Contracts\Rule
{
* @var string
private $validationMethod;
private $langKey;
* @var bool
private $status;
private $error;
* @var array
private $args;
* Rule constructor.
* @param string $validationMethod
* @param string $langKey
* @param array $args
public function __construct(string $validationMethod, string $langKey, $args = [])
$this->validationMethod = $validationMethod;
$this->langKey = $langKey;
$this->status = false;
$this->args = $args;
$this->error = '';
}
* @return string
public function getValidationMethod(): string
return $this->validationMethod;
public function getLangKey(): string
return $this->langKey;
* @return bool
public function getStatus(): bool
return $this->status;
* @param Language $language
* @param $value
public function isValid(Language $language, $value) : bool
if (!call_user_func_array(
'\\PluginSimpleValidate\\helper\\Validate\\' . $this->getValidationMethod(),
[
$value,
$this->args
]
)) {
$this->error = vsprintf(
$language->getTranslation(
$this->getLangKey()
),
);
} else {
$this->status = true;
public function getError(): string
return $this->error;