Skip to content

Commit

Permalink
Merge pull request #7 from yuvalherziger/master
Browse files Browse the repository at this point in the history
null if invalid boolean
  • Loading branch information
mpscholten authored Jun 29, 2016
2 parents ba083d6 + 5f2b92e commit c725a77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/BooleanParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ class BooleanParser extends AbstractValueParser
{
protected function parse($value)
{
return strtoupper($value) === 'TRUE' || strtoupper($value) === '1';
if (strtoupper($value) === 'TRUE' || $value === '1') {
return true;
}
if (strtoupper($value) === 'FALSE' || $value === '0') {
return false;
}
return null;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion src/YesNoBooleanParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ class YesNoBooleanParser extends AbstractValueParser
{
protected function parse($value)
{
return strtoupper($value) === 'YES' || strtoupper($value) === 'Y';
if (strtoupper($value) === 'YES' || strtoupper($value) === 'Y') {
return true;
}
if (strtoupper($value) === 'NO' || strtoupper($value) === 'N') {
return false;
}
return null;
}

/**
Expand Down

0 comments on commit c725a77

Please sign in to comment.