Skip to content

Commit f808639

Browse files
committed
[+]: Update README.md
1 parent b11959b commit f808639

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

README.md

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
102102
```
103103
104104
- **clear** *(empty array <=> [])*:
105+
> Set the contents of a given key or keys to the given value (default is empty array).
106+
105107
- ```php
106108
$dot->clear('books.{sci-fi & fantasy}');
107109
$dot->clear('books.{sci-fi & fantasy}', null);
@@ -117,12 +119,21 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
117119
$dot['books.{sci-fi & fantasy}'] = [];
118120
```
119121
122+
- **delete** *(unset(...))*:
123+
> Delete the given key or keys.
124+
125+
- ```php
126+
$dot->delete('books.{sci-fi & fantasy}');
127+
$dot->delete('books.{sci-fi & fantasy}.0.name');
128+
$dot->delete(['books.{sci-fi & fantasy}.0', 'books.{childre\'s books}.0']);
129+
```
130+
120131
- **merge**:
121-
> Merges one or more arrays into master recursively.
132+
> Merges one or more arrays into master recursively.<br/>
122133
If each array has an element with the same string key value, the latter
123-
will overwrite the former (different from array_merge_recursive).
134+
will overwrite the former (different from array_merge_recursive).<br/>
124135
Recursive merging will be conducted if both arrays have an element of array
125-
type and are having the same key.
136+
type and are having the same key.<br/>
126137
For integer-keyed elements, the elements from the latter array will
127138
be appended to the former array.
128139
@@ -144,30 +155,21 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
144155
);
145156
```
146157
147-
- **delete** *(unset(...))*:
148-
- ```php
149-
$dot->delete('books.{sci-fi & fantasy}');
150-
$dot->delete('books.{sci-fi & fantasy}.0.name');
151-
$dot->delete(['books.{sci-fi & fantasy}.0', 'books.{childre\'s books}.0']);
152-
```
153-
154158
- **find**:
159+
> Find the first item in an array that passes the truth test, otherwise return false.<br/>
160+
The signature of the callable must be: `function ($value, $key)`.
161+
155162
- ```php
156-
/*
157-
Find the first item in an array that passes the truth test, otherwise return false
158-
The signature of the callable must be: `function ($value, $key)`.
159-
*/
160163
$book = $dot->get('books.{childre\'s books}')->find(function ($value, $key) {
161164
return $value['price'] > 0;
162165
});
163166
```
164167
165168
- **filter**:
169+
> Use a callable function to filter through items.<br/>
170+
The signature of the callable must be: `function ($value, $key)`
171+
166172
- ```php
167-
/*
168-
Use a callable function to filter through items.
169-
The signature of the callable must be: `function ($value, $key)`
170-
*/
171173
$books = $dot->get('books.{childre\'s books}')->filter(function ($value, $key) {
172174
return $value['name'] === 'Harry Potter and the Order of the Phoenix';
173175
});
@@ -240,9 +242,9 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
240242
```
241243
242244
- **toArray**:
243-
- ```php
244-
// Getting the internal raw array.
245+
> Getting the internal raw array.
245246
247+
- ```php
246248
// Example 1.
247249
$dot->toArray();
248250
@@ -251,9 +253,9 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
251253
```
252254
253255
- **toJson**:
254-
- ```php
255-
// Getting the internal raw array as JSON.
256+
> Getting the internal raw array as JSON.
256257
258+
- ```php
257259
// Example 1.
258260
$dot->toJson();
259261

@@ -262,6 +264,9 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
262264
```
263265
264266
- **toFlat**:
267+
> Flatten the internal array using the dot delimiter,
268+
also the keys are wrapped inside {key} (1 x curly braces).
269+
265270
- ```php
266271
$dot = DotArray::create(
267272
[

src/DotArray.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ public function getIterator()
573573

574574

575575
/**
576+
* Getting the internal raw array.
577+
*
576578
* @return array
577579
*/
578580
public function toArray()
@@ -582,6 +584,8 @@ public function toArray()
582584

583585

584586
/**
587+
* Getting the internal raw array as JSON.
588+
*
585589
* @param int $options
586590
*
587591
* @return string

src/DotFilteringTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ protected static function operators()
110110

111111

112112
/**
113-
* Find the first item in an array that passes the truth test, otherwise return false
113+
* Find the first item in an array that passes the truth test, otherwise return false.
114114
* The signature of the callable must be: `function ($value, $key)`
115115
*
116116
* @param \Closure $closure

0 commit comments

Comments
 (0)