Return false instead of null for boolean attributes
This commit is contained in:
@@ -23,7 +23,15 @@ abstract class AbstractModel implements \JsonSerializable
|
||||
*/
|
||||
protected function get($field)
|
||||
{
|
||||
return isset($this->raw[$field]) ? $this->raw[$field] : null;
|
||||
if (isset($this->raw[$field])) {
|
||||
return $this->raw[$field];
|
||||
} else {
|
||||
if (preg_match('/^is_/', $field)) {
|
||||
return false;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,11 @@ abstract class AbstractRecord implements \JsonSerializable
|
||||
if ($this->__isset($attr)) {
|
||||
return $this->record[$key];
|
||||
} elseif ($this->validAttribute($attr)) {
|
||||
return null;
|
||||
if (preg_match('/^is_/', $key)) {
|
||||
return false;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
throw new \RuntimeException("Unknown attribute: $attr");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user