Skip to content

Commit 2cac2fb

Browse files
committed
wip
1 parent 1003341 commit 2cac2fb

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The MIT License (MIT)
1+
````# The MIT License (MIT)
22
33
Copyright (c) Spatie bvba <[email protected]>
44

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ The package will automatically register itself.
5151
- [`firstOrFail`](#firstorfail)
5252
- [`firstOrPush`](#firstorpush)
5353
- [`fromPairs`](#frompairs)
54-
- [`getDeeply`](#getdeeply)
5554
- [`glob`](#glob)
5655
- [`groupByModel`](#groupbymodel)
5756
- [`head`](#head)
@@ -66,6 +65,7 @@ The package will automatically register itself.
6665
- [`none`](#none)
6766
- [`paginate`](#paginate)
6867
- [`parallelMap`](#parallelmap)
68+
- [`path`](#path)
6969
- [`pluckMany`](#pluckmany)
7070
- [`pluckToArray`](#plucktoarray)
7171
- [`prioritize`](#prioritize)
@@ -354,23 +354,6 @@ $collection = collect([['a', 'b'], ['c', 'd'], ['e', 'f']])->fromPairs();
354354
$collection->toArray(); // returns ['a' => 'b', 'c' => 'd', 'e' => 'f']
355355
```
356356

357-
### `getDeeply`
358-
359-
Returns an item from the collection with multidimensional data using "dot" notation.
360-
Works the same way as native Collection's `pull` method, but without removing an item from the collection.
361-
362-
```php
363-
$collection = new Collection([
364-
'foo' => [
365-
'bar' => [
366-
'baz' => 100,
367-
]
368-
]
369-
]);
370-
371-
$collection->getDeeply('foo.bar.baz') // 100
372-
```
373-
374357
### `glob`
375358

376359
Returns a collection of a `glob()` result.
@@ -611,6 +594,23 @@ $pageSources = collect($urls)->parallelMap(function($url) {
611594

612595
This helps to reduce the memory overhead, as the default worker pool limit is `32` (as defined in `amphp/parallel`). Using fewer worker threads can significantly reduce memory and processing overhead, in many cases. Benchmark and customise the worker thread limit to suit your particular use-case.
613596

597+
### `path`
598+
599+
Returns an item from the collection with multidimensional data using "dot" notation.
600+
Works the same way as native Collection's `pull` method, but without removing an item from the collection.
601+
602+
```php
603+
$collection = new Collection([
604+
'foo' => [
605+
'bar' => [
606+
'baz' => 'value',
607+
]
608+
]
609+
]);
610+
611+
$collection->path('foo.bar.baz') // 'value'
612+
```
613+
614614
### `pluckMany`
615615

616616
Returns a collection with only the specified keys.

src/CollectionMacroServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ private function macros(): array
3131
'firstOrPush' => \Spatie\CollectionMacros\Macros\FirstOrPush::class,
3232
'fourth' => \Spatie\CollectionMacros\Macros\Fourth::class,
3333
'fromPairs' => \Spatie\CollectionMacros\Macros\FromPairs::class,
34-
'getDeeply' => \Spatie\CollectionMacros\Macros\GetDeeply::class,
3534
'getNth' => \Spatie\CollectionMacros\Macros\GetNth::class,
3635
'glob' => \Spatie\CollectionMacros\Macros\Glob::class,
3736
'groupByModel' => \Spatie\CollectionMacros\Macros\GroupByModel::class,
@@ -48,6 +47,7 @@ private function macros(): array
4847
'none' => \Spatie\CollectionMacros\Macros\None::class,
4948
'paginate' => \Spatie\CollectionMacros\Macros\Paginate::class,
5049
'parallelMap' => \Spatie\CollectionMacros\Macros\ParallelMap::class,
50+
'path' => \Spatie\CollectionMacros\Macros\Path::class,
5151
'pluckMany' => \Spatie\CollectionMacros\Macros\PluckMany::class,
5252
'pluckToArray' => \Spatie\CollectionMacros\Macros\PluckToArray::class,
5353
'prioritize' => \Spatie\CollectionMacros\Macros\Prioritize::class,

src/Macros/GetDeeply.php renamed to src/Macros/Path.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* @return mixed
1616
*/
17-
class GetDeeply
17+
class Path
1818
{
1919
public function __invoke()
2020
{

tests/Macros/GetDeeplyTest.php renamed to tests/Macros/PathTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Support\Collection;
66
use Spatie\CollectionMacros\Test\TestCase;
77

8-
class GetDeeplyTest extends TestCase
8+
class PathTest extends TestCase
99
{
1010
/** @test */
1111
public function it_retrieves_item_from_collection()
@@ -14,7 +14,7 @@ public function it_retrieves_item_from_collection()
1414

1515
$this->assertSame(
1616
'foo',
17-
$collection->getDeeply(0)
17+
$collection->path(0)
1818
);
1919
}
2020

@@ -31,7 +31,7 @@ public function it_retrieves_item_from_collection_using_dot_notation()
3131

3232
$this->assertSame(
3333
100,
34-
$collection->getDeeply('foo.bar.baz')
34+
$collection->path('foo.bar.baz')
3535
);
3636
}
3737

@@ -40,7 +40,7 @@ public function it_doesnt_remove_item_from_collection()
4040
{
4141
$collection = new Collection(['foo', 'bar']);
4242

43-
$collection->getDeeply(0);
43+
$collection->path(0);
4444

4545
$this->assertEquals(
4646
[
@@ -58,7 +58,7 @@ public function it_returns_default()
5858

5959
$this->assertSame(
6060
'foo',
61-
$collection->getDeeply(0, 'foo')
61+
$collection->path(0, 'foo')
6262
);
6363
}
6464
}

0 commit comments

Comments
 (0)