diff --git a/src/Collection.php b/src/Collection.php index 7cb5ba0..f6c91cc 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -55,11 +55,19 @@ public function add($value, $key = null) * * @param mixed $key * - * @return mixed|null + * @return int|string|null|Collection */ public function get($key) { - return $this->elements[$key] ?? null; + if (!array_key_exists($key, $this->elements)) { + return null; + } + + if (!is_array($this->elements[$key])) { + return $this->elements[$key]; + } + + return self::collect($this->elements[$key]); } /**