public static function keyExists($collection, $key, $magicIsAllowed = false)
{
if ($magicIsAllowed && is_object($collection) && method_exists($collection, '__get')) {
return true;
}
if (is_array($collection) || $collection instanceof \ArrayAccess) {
return array_key_exists($key, $collection);
} else {
if (is_object($collection)) {
return property_exists($collection, $key);
}
}
}