Skip to content

Commit 44ccd49

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents e449a35 + 3edc636 commit 44ccd49

File tree

7 files changed

+135
-5
lines changed

7 files changed

+135
-5
lines changed

docs/README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
1-
# Documentation
1+
# Minwork Array
22

3-
### Welcome to the documentation page
3+
## Welcome to the documentation page
4+
5+
Minwork Array library is focused on conviniently handling nested arrays as well as arrays of objects.
46

57
{% hint style="info" %}
68
Detailed documentation is always available through PHPDoc in your editor, so you can access it anytime.
79
{% endhint %}
810

9-
We believe that the best way to learn some code is to see examples of using it.
10-
That's why aside from detailed specification of each method we supply various examples of using it which will help in faster understanding it's purpose.
11+
I believe that the best way to learn some code is to see it in action. That's why within this documentation, aside from detailed specification of each method you will find various examples of using it which will help in faster understanding it's purpose and applications.
12+
13+
To quickly get started check out the links below or look at the full list of available methods in the left panel.
14+
15+
{% page-ref page="common-methods/has.md" %}
16+
17+
{% page-ref page="common-methods/get-getnestedelement.md" %}
18+
19+
{% page-ref page="common-methods/set-setnestedelement.md" %}
20+
21+
{% page-ref page="common-methods/remove.md" %}
22+
23+
{% page-ref page="utility-methods/getfirstkey.md" %}
24+
25+
{% page-ref page="utility-methods/getfirstvalue.md" %}
1126

12-
To quickly get started check out [get](common-methods/get-getnestedelement.md), [set](common-methods/set-setnestedelement.md), [has](common-methods/has.md) and [remove](common-methods/remove.md) methods or look at the full list of available methods in the left panel\.

docs/SUMMARY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@
4141
* [random](utility-methods/random.md)
4242
* [shuffle](utility-methods/shuffle.md)
4343
* [nth](utility-methods/nth.md)
44+
* [getFirstKey](utility-methods/getfirstkey.md)
45+
* [getLastKey](utility-methods/getlastkey.md)
46+
* [getFirstValue](utility-methods/getfirstvalue.md)
47+
* [getLastValue](utility-methods/getlastvalue.md)
4448

docs/manipulating-array/mapping.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ Applies a callback to the elements of given array. Arguments supplied to callbac
1616
For backward compatibility using `map(callable, array)` is still possible but is deprecated and will issue appropriate warning
1717
{% endhint %}
1818

19+
#### Modes
20+
21+
| Constant name | Description |
22+
| :--- | :--- |
23+
| MAP\_ARRAY\_KEY\_VALUE | Map array using callback in form of `function($key, $value)` |
24+
| MAP\_ARRAY\_VALUE\_KEYS\_LIST | Map array using callback in form of `function($value, $key1, $key2, ...)` |
25+
| MAP\_ARRAY\_KEYS\_ARRAY\_VALUE | Map array using callback in form of `function(array $keys, $value)` |
26+
| MAP\_ARRAY\_VALUE\_KEY | Map array using callback in form of `function($value, $key)` |
27+
1928
#### Examples
2029

2130
```php
@@ -34,6 +43,10 @@ $array2 = [
3443
$mapKeyValue = function ($key, $value) {
3544
return "{$key} -> {$value}";
3645
};
46+
// Mind that $value is a first argument here
47+
$mapValueKey = function ($value, $key) {
48+
return "{$key} -> {$value}";
49+
};
3750
$mapKeysValue = function ($keys, $value) {
3851
return implode('.', $keys) . " -> {$value}";
3952
};
@@ -44,6 +57,9 @@ $mapValueKeysList = function ($value, $key1, $key2) {
4457
// Equivalent to using MAP_ARRAY_KEY_VALUE as mode (3rd) argument
4558
Arr::map($array1, $mapKeyValue) -> ['0 -> a', '1 -> b', '2 -> c']
4659

60+
// Resemble array_map function but with array supplied as first argument
61+
Arr::map($array1, $mapValueKey) -> ['0 -> a', '1 -> b', '2 -> c']
62+
4763
// Map multidimensional array using keys array
4864
Arr::map($array2, $mapKeysValue, Arr::MAP_ARRAY_KEYS_ARRAY_VALUE) ->
4965
[

docs/utility-methods/getfirstkey.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# getFirstKey
2+
3+
#### Definition
4+
5+
```php
6+
Arr::getFirstKey(array $array): int|string|null
7+
```
8+
9+
#### Description
10+
11+
Get the first key of the given array without affecting the internal array pointer.
12+
13+
Returns `null` if array is empty.
14+
15+
#### Examples
16+
17+
```php
18+
Arr::getFirstKey(['a' => 1, 'b' => 2, 'c' => 3]) -> 'a'
19+
20+
Arr::getFirstKey([1, 2, 3]) -> 0
21+
22+
Arr::getFirstKey([]) -> null
23+
```
24+

docs/utility-methods/getfirstvalue.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# getFirstValue
2+
3+
#### Definition
4+
5+
```php
6+
Arr::getFirstValue(array $array): mixed|null
7+
```
8+
9+
#### Description
10+
11+
Get the first value of the given array without affecting the internal array pointer.
12+
13+
Returns `null` if array is empty.
14+
15+
#### Examples
16+
17+
```php
18+
Arr::getFirstValue(['a' => 1, 'b' => 2, 'c' => 3]) -> 1
19+
20+
Arr::getFirstValue([1, 2, 3, 4, 5]) -> 1
21+
22+
Arr::getFirstValue([]) -> null
23+
```
24+

docs/utility-methods/getlastkey.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# getLastKey
2+
3+
#### Definition
4+
5+
```php
6+
Arr::getLastKey(array $array): int|string|null
7+
```
8+
9+
#### Description
10+
11+
Get the last key of the given array without affecting the internal array pointer.
12+
13+
Returns `null` if array is empty.
14+
15+
#### Examples
16+
17+
```php
18+
Arr::getLastKey(['a' => 1, 'b' => 2, 'c' => 3]) -> 'c'
19+
20+
Arr::getLastKey([1, 2, 3]) -> 2
21+
22+
Arr::getLastKey([]) -> null
23+
```
24+

docs/utility-methods/getlastvalue.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# getLastValue
2+
3+
#### Definition
4+
5+
```php
6+
Arr::getLastValue(array $array): mixed|null
7+
```
8+
9+
#### Description
10+
11+
Get the last value of the given array without affecting the internal array pointer.
12+
13+
Returns `null` if array is empty.
14+
15+
#### Examples
16+
17+
```php
18+
Arr::getLastValue(['a' => 1, 'b' => 2, 'c' => 3]) -> 3
19+
20+
Arr::getLastValue([1, 2, 3, 4, 5]) -> 5
21+
22+
Arr::getLastValue([]) -> null
23+
```
24+

0 commit comments

Comments
 (0)