Skip to content

Commit

Permalink
Redundant implicit method (#3)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
hoshomoh authored May 24, 2018
1 parent 6cd5913 commit 561764b
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 72 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions src/Contracts/ValidationRuleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions src/Rules/AsciiOnly.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
10 changes: 0 additions & 10 deletions src/Rules/Between.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
10 changes: 0 additions & 10 deletions src/Rules/ClosureValidationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
10 changes: 0 additions & 10 deletions src/Rules/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
10 changes: 3 additions & 7 deletions src/Validator/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand Down
7 changes: 0 additions & 7 deletions tests/src/UppercaseRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@

class UppercaseRule implements ValidationRuleInterface
{
/**
* @return boolean
*/
public function isImplicit()
{
return true;
}

/**
* @return integer
Expand Down

0 comments on commit 561764b

Please sign in to comment.