I have this example pseudo-code that works, $x basically is an object with keys and values or array with keys and objects as values. $y will be constructed in two different ways.
private function someFunction($x) {
if (is_object($x)) {
$y = 'result of something';
} elseif (is_array($x)) {
$y = 'result of something';
} else {
$y = null;
}
return $y;
}
Is this a good practice, if function will not be used anywhere else? 'Non-hack' way probably is to convert object to an array (because it is an array in essence) and then make logic based on count of arrays.
Or am I just thinking to much about writing code 'right way'?