Skip to content

Commit 7297dfa

Browse files
committed
Improved README content
- More descriptive - Direct links to methods documentation - Added examples
1 parent 44ccd49 commit 7297dfa

File tree

1 file changed

+52
-10
lines changed

1 file changed

+52
-10
lines changed

README.md

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22

33
[![Build Status](https://camo.githubusercontent.com/e98c32cb27c2f579cc8a8472235668692d3ef75f/68747470733a2f2f7472617669732d63692e6f72672f6d696e776f726b2f61727261792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/minwork/array) [![Coverage Status](https://camo.githubusercontent.com/5597efd400c8dc6e11b7e0246ad03de2c5437b2a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d696e776f726b2f61727261792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/minwork/array?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/8d4c9f33e111bea52ddeb53c915e8d4f32e143b9/68747470733a2f2f706f7365722e707567782e6f72672f6d696e776f726b2f61727261792f762f737461626c65)](https://packagist.org/packages/minwork/array) [![License](https://camo.githubusercontent.com/3dfeab76bf8b4c567a0b23fb7e381dff9f1b2ba9/68747470733a2f2f706f7365722e707567782e6f72672f6d696e776f726b2f61727261792f6c6963656e7365)](https://packagist.org/packages/minwork/array)
44

5-
* Pack of advanced array functions best suited for:
6-
* **Multidimensional** arrays
5+
## Pack of array convenience methods for handling:
6+
* **Nested** arrays
77
* Arrays of **objects**
88
* **Associative** arrays
9-
* Easily **access**, **validate**, **manipulate** and **transform** arrays
10-
* Advanced implementation of well known operations
11-
* Map
12-
* Filter
13-
* Group
14-
* Sort
15-
* Check
16-
* And many more...
9+
* **Chaining** array transformations
10+
### Easily **create**, **access**, **validate**, **manipulate** and **transform** arrays
11+
Advanced implementation of well known operations:
12+
* [Get](https://minwork.gitbook.io/array/common-methods/get-getnestedelement)
13+
* [Set](https://minwork.gitbook.io/array/common-methods/set-setnestedelement)
14+
* [Has](https://minwork.gitbook.io/array/common-methods/has)
15+
* [Map](https://minwork.gitbook.io/array/manipulating-array/mapping)
16+
* [Filter](https://minwork.gitbook.io/array/manipulating-array/filtering)
17+
* [Group](https://minwork.gitbook.io/array/manipulating-array/grouping)
18+
* [Sort](https://minwork.gitbook.io/array/manipulating-array/sorting)
19+
* [Check](https://minwork.gitbook.io/array/validating-array/check)
20+
* [And many more...](https://minwork.gitbook.io/array/)
1721

1822
## Installation
1923

@@ -27,6 +31,44 @@
2731
* No external dependencies
2832
* Large variety of usages
2933

34+
## Example of usage
35+
```php
36+
// Set nested array value
37+
$array = Arr::set([], 'key1.key2.key3', 'my_value');
38+
39+
// Get nested array value
40+
Arr::get($array, 'key1.key2') -> ['key3' => 'my_value']
41+
42+
// Check if array has nested element
43+
Arr::has($array, 'key1.key2.key3') -> true
44+
45+
// Map array while accessing it's key
46+
Arr::map($array, function ($key, $value) {
47+
// Your code here
48+
});
49+
50+
// Chain few methods
51+
Arr::obj(['test' => 1, 'foo' => 'bar'])
52+
->set('abc', 123)
53+
->set('[]', 'auto_index')
54+
->remove('foo')
55+
->getArray()
56+
->
57+
[
58+
'test' => 1,
59+
'abc' => 123,
60+
'auto_index'
61+
]
62+
63+
// Group objects by the result of calling method 'getSize' on each object
64+
Arr::groupObjects([$cat, $dog, $fish, ...], 'getSize') ->
65+
[
66+
'medium' => [$cat, $dog, ...],
67+
'small' => [$fish, ...],
68+
...
69+
]
70+
```
71+
3072
## Documentation
3173

3274
[https://minwork.gitbook.io/array/](https://minwork.gitbook.io/array/)

0 commit comments

Comments
 (0)