In addition to @konsolebox's answer, you can also silently convert empty strings to NULL
s inside the get()
method:
public function get($param, $default = null) {
if ($default === '') {
$default = null;
}
// ...
The advantage to this is that when your default is dynamic (passed in as a variable), and it happens to be an empty string, it still produces the desired effect:
$default = '';
$test = $post->get('url', $default); // null