Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 18, 2018
1 parent 434a82c commit af36f26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
6 changes: 5 additions & 1 deletion src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,11 @@ public function forget($keys)
*/
public function get($key, $default = null)
{
return is_null($key) ? null : Arr::get($this->items, $key, $default);
if ($this->offsetExists($key)) {
return $this->items[$key];
}

return value($default);
}

/**
Expand Down
21 changes: 0 additions & 21 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2465,27 +2465,6 @@ public function testUnlessDefault()
$this->assertSame(['michael', 'tom', 'taylor'], $collection->toArray());
}

public function testGetNestedValue()
{
$collection = new Collection([
'foo' => [
'bar' => 'baz',
'books' => [
'Book 1',
'Book 2',
],
'todos' => [
'first' => 'Todo 1',
'second' => 'Todo 2',
],
],
]);

$this->assertEquals('baz', $collection->get('foo.bar'));
$this->assertEquals('Book 1', $collection->get('foo.books.0'));
$this->assertEquals('Todo 2', $collection->get('foo.todos.second'));
}

public function testGetWithNullReturnsNull()
{
$collection = new Collection([1, 2, 3]);
Expand Down

0 comments on commit af36f26

Please sign in to comment.