/** * Get an attribute from the container. * * @param string $key * @param mixed $default * * @return mixed */ public function get($key, $default = null) { if (array_key_exists($key, $this->attributes)) { return $this->attributes[$key]; } return Misc::value($default); }
/** * Get an item from the collection by key. * * @param mixed $key * @param mixed $default * * @return mixed */ public function get($key, $default = null) { if ($this->offsetExists($key)) { return $this->items[$key]; } return Misc::value($default); }
/** * Get an item from an array using "dot" notation. * * @param \ArrayAccess|array $array * @param string $key * @param mixed $default * * @return mixed */ public static function get($array, $key, $default = null) { if (!static::accessible($array)) { return Misc::value($default); } if (is_null($key)) { return $array; } if (static::exists($array, $key)) { return $array[$key]; } foreach (explode('.', $key) as $segment) { if (static::accessible($array) && static::exists($array, $segment)) { $array = $array[$segment]; } else { return Misc::value($default); } } return $array; }