public static function exists($arr, $key) {
        // If it's an object, index directly because array_key_exists doesn't
        // work with the ArrayAccess interface. Otherwise, check if it implements
        // ArrayAccess and fall back to array_key_exists.
        if(is_object($arr)) {
            return $arr->offsetExists($key);
        }
        if(is_array($arr)) {
            return array_key_exists($key, $arr);
        }

        return false;
    }