I have a Class where most of the Methods are required to run. I normally call these methods after I've instantiated the Object.
<?php
try {
$obj = new MyClassName();
$obj->Method1($var);
$obj->Method2($var);
$obj->Method3($var);
$obj->Method4($var);
} catch(Exception $e) {
}
?>
As my Class grows, and more Methods get introduced, I find that I need to ensure that certain Methods get called.
At first, I was calling all my required Methods within the __construct()
, then calling those same Methods again, in case I need to alter things.
My other validation technique is to run get_object_vars()
and check for the existence of specific properties.
I don't mind my current way to validate, but I have to inquire if there's an easier/better way.