From 561764b1c5ff424ca76273ec26bed4e4e43d8e91 Mon Sep 17 00:00:00 2001 From: Oforomeh Oshomo Date: Thu, 24 May 2018 07:04:55 +0100 Subject: [PATCH] Redundant implicit method (#3) - Removed redundant isImplicit method for validator interface - Removed isImplicit from rules that have implemented validator interface - Removed isImplicit from custom uppercase rule created for test - Updated README --- README.md | 10 ---------- src/Contracts/ValidationRuleInterface.php | 8 -------- src/Rules/AsciiOnly.php | 10 ---------- src/Rules/Between.php | 10 ---------- src/Rules/ClosureValidationRule.php | 10 ---------- src/Rules/Url.php | 10 ---------- src/Validator/Validator.php | 10 +++------- tests/src/UppercaseRule.php | 7 ------- 8 files changed, 3 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 21e8158..0a19860 100644 --- a/README.md +++ b/README.md @@ -156,16 +156,6 @@ use Oshomo\CsvUtils\Contracts\ValidationRuleInterface; class UppercaseRule implements ValidationRuleInterface { - /** - * Determine if the validation rule accepts parameters or not. - * If it does not accept any parameter return true else return false - * - * @return boolean - */ - public function isImplicit() - { - return true; - } /** * Get the number of parameters that should be supplied. diff --git a/src/Contracts/ValidationRuleInterface.php b/src/Contracts/ValidationRuleInterface.php index 55fa138..ce1fa48 100644 --- a/src/Contracts/ValidationRuleInterface.php +++ b/src/Contracts/ValidationRuleInterface.php @@ -5,14 +5,6 @@ interface ValidationRuleInterface { - /** - * Determine if the validation rule accepts parameters or not. - * If it does not accept any parameter return true else return false - * - * @return boolean - */ - public function isImplicit(); - /** * Get the number of parameters that should be supplied. * If no parameter should be supplied return 0 else diff --git a/src/Rules/AsciiOnly.php b/src/Rules/AsciiOnly.php index 16276ff..fa7be90 100644 --- a/src/Rules/AsciiOnly.php +++ b/src/Rules/AsciiOnly.php @@ -8,16 +8,6 @@ class AsciiOnly implements ValidationRuleInterface { - /** - * Determine if the validation rule accepts parameters or not. - * - * @return boolean - */ - public function isImplicit() - { - return true; - } - /** * Get the number of parameters that should be supplied * diff --git a/src/Rules/Between.php b/src/Rules/Between.php index fb94a75..716fd47 100644 --- a/src/Rules/Between.php +++ b/src/Rules/Between.php @@ -9,16 +9,6 @@ class Between implements ValidationRuleInterface { const PARAMETER_COUNT = 2; - /** - * Determine if the validation rule accepts parameters or not. - * - * @return boolean - */ - public function isImplicit() - { - return false; - } - /** * Get the number of parameters that should be supplied * diff --git a/src/Rules/ClosureValidationRule.php b/src/Rules/ClosureValidationRule.php index 1e31a8a..d276cd0 100755 --- a/src/Rules/ClosureValidationRule.php +++ b/src/Rules/ClosureValidationRule.php @@ -39,16 +39,6 @@ public function __construct($callback) $this->callback = $callback; } - /** - * Determine if the validation rule accepts parameters or not. - * - * @return boolean - */ - public function isImplicit() - { - return true; - } - /** * Get the number of parameters that should be supplied * diff --git a/src/Rules/Url.php b/src/Rules/Url.php index 63b1414..9ff913b 100644 --- a/src/Rules/Url.php +++ b/src/Rules/Url.php @@ -8,16 +8,6 @@ class Url implements ValidationRuleInterface { - /** - * Determine if the validation rule accepts parameters or not. - * - * @return boolean - */ - public function isImplicit() - { - return true; - } - /** * Get the number of parameters that should be supplied * diff --git a/src/Validator/Validator.php b/src/Validator/Validator.php index 696ec6e..b49eaba 100755 --- a/src/Validator/Validator.php +++ b/src/Validator/Validator.php @@ -378,13 +378,9 @@ protected function passesParameterCheck($rule, $parameters) $rule = $this->getRuleClass($rule); } - if ($rule->isImplicit()) { - return true; - } else { - $ruleParameterCount = $rule->parameterCount(); - $parameterCount = count($parameters); - return ($ruleParameterCount === 0) ? true : ($parameterCount === $ruleParameterCount); - } + $ruleParameterCount = $rule->parameterCount(); + $parameterCount = count($parameters); + return ($ruleParameterCount === 0) ? true : ($parameterCount === $ruleParameterCount); } diff --git a/tests/src/UppercaseRule.php b/tests/src/UppercaseRule.php index e28b89f..16654c2 100644 --- a/tests/src/UppercaseRule.php +++ b/tests/src/UppercaseRule.php @@ -7,13 +7,6 @@ class UppercaseRule implements ValidationRuleInterface { - /** - * @return boolean - */ - public function isImplicit() - { - return true; - } /** * @return integer