Behaviour of Content::is_empty()
Currently the Content::is_empty()
function is defined as:
public function is_empty() {
return is_null($this->content);
}
Is there a specific reason why is_null()
is used here instead of is_empty()
?
Having is_null()
is sometimes annoying, for example when I want to do something like:
$ul = new Kolombido\HTML\ListElt();
if ($condition) $ul->item('List item');
if (!$ul->is_empty()) echo $ul;
This doesn't work as I expected when $condition
evaluates to false
as instances of HTML\ListElt
are constructed with the empty string as their content. If it's not desirable to change from is_null()
to is_empty()
I think we should override how is_empty()
behaves in the case of HTML\ListElt
objects.