offsetExists($key); } return array_key_exists($key, $array); } public static function accessible($value) { return is_array($value) || $value instanceof ArrayAccess; } public static function get($array, $key, $default = null) { if (!static::accessible($array)) { return $default; } $value = null; if (is_null($key)) { $value = $array; } if (static::exists($array, $key)) { $value = $array[$key]; } if (strpos($key, '.') === false) { $value = isset($array[$key]) ? $array[$key] : $default; } foreach (explode('.', $key) as $segment) { if (static::accessible($array) && static::exists($array, $segment)) { $value = $array[$segment]; $array = $array[$segment]; } else { $value = $default; break; } } return !is_null($value) ? $value : $default; } public static function only($array, $keys) { return array_intersect_key($array, array_flip((array)$keys)); } }