Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/zendframework/zendframework#6277-digit-filter-sh…
Browse files Browse the repository at this point in the history
…ould-ignore-booleans' into develop

Close zendframework/zendframework#6277
Forward Port zendframework/zendframework#6277
  • Loading branch information
Ocramius committed May 20, 2014
5 parents 2714d51 + bc13fad + 6b484d8 + fda1abb + def9372 commit 163c322
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/Digits.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ class Digits extends AbstractFilter
*
* Returns the string $value, removing all but digit characters
*
* If the value provided is non-scalar, the value will remain unfiltered
* If the value provided is not integer, float or string, the value will remain unfiltered
*
* @param string $value
* @return string|mixed
*/
public function filter($value)
{
if (!is_scalar($value)) {
if (is_int($value)) {
return (string) $value;
}
if (! (is_float($value) || is_string($value))) {
return $value;
}
$value = (string) $value;
Expand Down
6 changes: 4 additions & 2 deletions test/DigitsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public function returnUnfilteredDataProvider()
array(array(
'abc123',
'abc 123'
))
)),
array(true),
array(false),
);
}

Expand All @@ -102,6 +104,6 @@ public function testReturnUnfiltered($input)
{
$filter = new DigitsFilter();

$this->assertEquals($input, $filter($input));
$this->assertSame($input, $filter($input));
}
}

0 comments on commit 163c322

Please sign in to comment.