From 15142fb0f4e5018f35fe76f8975191bb79b17178 Mon Sep 17 00:00:00 2001 From: Karsten Lettow Date: Tue, 7 Mar 2017 15:21:55 +0100 Subject: [PATCH] added workaround --- src/Validator/StringLengthBetween.php | 7 +++---- src/Validator/StringLengthLargerThanOrEqualToParser.php | 7 +++---- src/Validator/StringLengthLargerThanParser.php | 7 +++---- src/Validator/StringLengthSmallerThanOrEqualToParser.php | 7 +++---- src/Validator/StringLengthSmallerThanParser.php | 7 +++---- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/Validator/StringLengthBetween.php b/src/Validator/StringLengthBetween.php index d0df507..3b89b0d 100644 --- a/src/Validator/StringLengthBetween.php +++ b/src/Validator/StringLengthBetween.php @@ -15,11 +15,10 @@ protected function describe() */ protected function parse($value) { - if (!is_string($value)) { - return null; + if (strlen($value) >= $this->minValue && strlen($value) <= $this->maxValue) { + return $value; } - $value = strlen($value); - return parent::parse($value); + return null; } /** diff --git a/src/Validator/StringLengthLargerThanOrEqualToParser.php b/src/Validator/StringLengthLargerThanOrEqualToParser.php index 112e5ec..e170eab 100644 --- a/src/Validator/StringLengthLargerThanOrEqualToParser.php +++ b/src/Validator/StringLengthLargerThanOrEqualToParser.php @@ -15,11 +15,10 @@ protected function describe() */ protected function parse($value) { - if (!is_string($value)) { - return null; + if (strlen($value) >= $this->minValue) { + return $value; } - $value = strlen($value); - return parent::parse($value); + return null; } /** diff --git a/src/Validator/StringLengthLargerThanParser.php b/src/Validator/StringLengthLargerThanParser.php index eb4b1a7..04c46ef 100644 --- a/src/Validator/StringLengthLargerThanParser.php +++ b/src/Validator/StringLengthLargerThanParser.php @@ -15,11 +15,10 @@ protected function describe() */ protected function parse($value) { - if (!is_string($value)) { - return null; + if (strlen($value) > $this->minValue) { + return $value; } - $value = strlen($value); - return parent::parse($value); + return null; } /** diff --git a/src/Validator/StringLengthSmallerThanOrEqualToParser.php b/src/Validator/StringLengthSmallerThanOrEqualToParser.php index 32143cb..f187878 100644 --- a/src/Validator/StringLengthSmallerThanOrEqualToParser.php +++ b/src/Validator/StringLengthSmallerThanOrEqualToParser.php @@ -15,11 +15,10 @@ protected function describe() */ protected function parse($value) { - if (!is_string($value)) { - return null; + if (strlen($value) <= $this->maxValue) { + return $value; } - $value = strlen($value); - return parent::parse($value); + return null; } /** diff --git a/src/Validator/StringLengthSmallerThanParser.php b/src/Validator/StringLengthSmallerThanParser.php index d2d0691..3f948ff 100644 --- a/src/Validator/StringLengthSmallerThanParser.php +++ b/src/Validator/StringLengthSmallerThanParser.php @@ -15,11 +15,10 @@ protected function describe() */ protected function parse($value) { - if (!is_string($value)) { - return null; + if (strlen($value) < $this->maxValue) { + return $value; } - $value = strlen($value); - return parent::parse($value); + return null; } /**