I have a class that contains a bunch of averages, but if there is no data all the fields will be NULL
, and in the eyes of my logic, "empty". However, wrapping my class in if(empty($myClassInstance))
returns false, which is correct, but I was wondering if there is any magic methods in PHP where I could say "If this objected is checked for being empty, do some stuff and return a bool"?
I realise I can add a isEmpty()
method, I am just curious if this is something that can be done.