```php
    // using isset for performance reasons

    if (isset($array[$key]))
        return $array[$key];

    if ($array === NULL)
        return $default;

    if (is_array($array))
    {
        return array_key_exists($key, $array) ? $array[$key] : $default;
    }
    elseif ($array->offsetExists($key))
    {
        return $array[$key];

    }
    
    throw new Kohana_Exception('Argument 1 to Arr::get() must be an array or an instance of ArrayAccess');
```