Skip to content

Commit abb88f2

Browse files
committed
Initial commit
0 parents  commit abb88f2

11 files changed

Lines changed: 3601 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
.phpunit.result.cache
3+
/vendor/

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Hadi Akbarzadeh
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Stringer (String Helper for PHP)
2+
3+
> An array helper for PHP. It includes some useful methods and possibly other features.
4+
5+
Some of the methods from the Arr class of the Laravel framework are also included in this library;
6+
however, some of them have been modified.
7+
8+
<hr>
9+
10+
## 🫡 Usage
11+
12+
### 🚀 Installation
13+
14+
You can install the package via composer:
15+
16+
```bash
17+
composer require nabeghe/arrayer
18+
```
19+
20+
<hr>
21+
22+
### Str Class
23+
24+
The main class that includes the useful methods is `Nabegh\String\Arr`.
25+
26+
#### Example:
27+
28+
```php
29+
use Nabeghe\Stringer\Arr;
30+
31+
use Nabeghe\Arrayer\Arr;
32+
33+
$data1 = ['key_1' => 'value_1', 'key_3' => ['key_3_1' => 'value_3_1']];
34+
35+
$data2 = ['key_2' => 'value_2'];
36+
37+
$data3 = ['key_3' => ['key_3_2' => 'value_3_2']];
38+
39+
$merged = Arr::merge($data1, $data2, $data3);
40+
41+
print_r($merged);
42+
43+
/*
44+
Array
45+
(
46+
[key_1] => value_1
47+
[key_3] => Array
48+
(
49+
[key_3_1] => value_3_1
50+
[key_3_2] => value_3_2
51+
)
52+
53+
[key_2] => value_2
54+
)
55+
*/
56+
```
57+
58+
<hr>
59+
60+
### Arrayer Class
61+
62+
An array class.
63+
64+
Accepts any value, converts it to an array via `Arr::cast`, stores it, and returns it via `data` property.
65+
66+
It is possible to access the methods of the `Arr` class through the `Arrayer` object as well, with the difference that the main array parameter is no longer present.
67+
68+
Additionally, the `ArrayAccess` and `JsonSerializable` interfaces have also been implemented on `Arrayer` class.
69+
70+
```php
71+
use Nabeghe\Arrayer\Arrayer;
72+
73+
$data1 = ['key_1' => 'value_1', 'key_3' => ['key_3_1' => 'value_3_1']];
74+
75+
$data2 = ['key_2' => 'value_2'];
76+
77+
$data3 = ['key_3' => ['key_3_2' => 'value_3_2']];
78+
79+
$arrayer = new Arrayer();
80+
81+
print_r($arrayer->merge($data1, $data2, $data3)->data);
82+
83+
/*
84+
Array
85+
(
86+
[key_1] => value_1
87+
[key_3] => Array
88+
(
89+
[key_3_1] => value_3_1
90+
[key_3_2] => value_3_2
91+
)
92+
93+
[key_2] => value_2
94+
)
95+
*/
96+
```
97+
98+
<hr>
99+
100+
## 📖 License
101+
102+
Copyright (c) 2024 Hadi Akbarzadeh
103+
104+
Licensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.

composer.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "nabeghe/arrayer",
3+
"description": "An array helper for PHP. It includes some useful methods and possibly other features.",
4+
"keywords": [
5+
"array", "array helper", "array utils", "array merge", "library", "helper", "support"
6+
],
7+
"type": "library",
8+
"version": "1.0.0",
9+
"homepage": "https://github.com/nabeghe/arrayer-php",
10+
"license": "MIT",
11+
"autoload": {
12+
"psr-4": {
13+
"Nabeghe\\Arrayer\\": "src/"
14+
}
15+
},
16+
"authors": [
17+
{
18+
"name": "Hadi Akbarzadeh",
19+
"email": "hadicoder@gmail.com"
20+
}
21+
],
22+
"require": {
23+
"php": ">=7.4",
24+
"ext-json": "*",
25+
"nabeghe/cally": "*",
26+
"nabeghe/stringer": "*"
27+
},
28+
"require-dev": {
29+
"phpunit/phpunit": "9.6"
30+
}
31+
}

0 commit comments

Comments
 (0)