Skip to content

Commit

Permalink
[5.3] Changing the name of the method mapToAssoc() to mapWithKeys() (l…
Browse files Browse the repository at this point in the history
…aravel#14799)

* Another name for the mapToAssoc

* Changing the test accordingly

* Removing typo

* Fixing phpdoc

* Reverting changes to the phpdoc
  • Loading branch information
fernandobandeira authored and taylorotwell committed Aug 18, 2016
1 parent 6e77be5 commit 79bf440
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public function map(callable $callback)
* @param callable $callback
* @return static
*/
public function mapToAssoc(callable $callback)
public function mapWithKeys(callable $callback)
{
return $this->flatMap($callback);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -895,14 +895,14 @@ public function testFlatMap()
$this->assertEquals(['programming', 'basketball', 'music', 'powerlifting'], $data->all());
}

public function testMapToAssoc()
public function testMapWithKeys()
{
$data = new Collection([
['name' => 'Blastoise', 'type' => 'Water', 'idx' => 9],
['name' => 'Charmander', 'type' => 'Fire', 'idx' => 4],
['name' => 'Dragonair', 'type' => 'Dragon', 'idx' => 148],
]);
$data = $data->mapToAssoc(function ($pokemon) {
$data = $data->mapWithKeys(function ($pokemon) {
return [$pokemon['name'] => $pokemon['type']];
});
$this->assertEquals(
Expand Down

0 comments on commit 79bf440

Please sign in to comment.