Skip to content

Commit

Permalink
Optimize Boolean::validate() method implementation (particle-php#151)
Browse files Browse the repository at this point in the history
* Optimize `Boolean::validate()` method implementation

* Refactor `Boolean::validate()` method expression

* Refactor `Boolean::validate()` method to use short ternary operator
  • Loading branch information
creocoder authored and Rick van der Staaij committed Oct 3, 2016
1 parent c85b498 commit ee679b1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/Rule/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class Boolean extends Rule
*/
public function validate($value)
{
if ($value === true || $value === false) {
return true;
}
return $this->error(self::NOT_BOOL);
return is_bool($value) ?: $this->error(self::NOT_BOOL);
}
}

0 comments on commit ee679b1

Please sign in to comment.