Skip to content

Commit 139ffa4

Browse files
committed
Renamed unset method to remove
1 parent 3c62ee8 commit 139ffa4

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/Arr.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ public static function setNestedElement(array $array, $keys, $value): array
214214
}
215215

216216
/**
217-
* Destroy variable inside array at path specified by keys
217+
* Remove element inside array at path specified by keys
218218
*
219219
* @param array $array
220220
* @param mixed $keys Keys needed to access desired array element (for possible formats see getKeysArray method)
221221
* @return array
222222
* @see Arr::getKeysArray()
223223
*/
224-
public static function unset(array $array, $keys): array
224+
public static function remove(array $array, $keys): array
225225
{
226226
$result = self::clone($array);
227227
$keysArray = self::getKeysArray($keys);

test/ArrTest.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function testSetNestedElement()
154154
$this->assertSame(Arr::setNestedElement($array, 'key1.key2', ['key3' => 'test']), Arr::set($array, 'key1.key2', ['key3' => 'test']));
155155
}
156156

157-
public function testUnset()
157+
public function testRemove()
158158
{
159159
$array = [
160160
'test' => [
@@ -169,15 +169,15 @@ public function testUnset()
169169
],
170170
];
171171

172-
$this->assertSame([], Arr::unset($array, 'test'));
172+
$this->assertSame([], Arr::remove($array, 'test'));
173173
$this->assertSame([
174174
'test' => [
175175
'test1',
176176
[
177177
'test6' => 'def'
178178
],
179179
],
180-
], Arr::unset($array, 'test.test2'));
180+
], Arr::remove($array, 'test.test2'));
181181

182182
$this->assertSame([
183183
'test' => [
@@ -189,7 +189,7 @@ public function testUnset()
189189
'test6' => 'def'
190190
],
191191
]
192-
], Arr::unset($array, 'test.0'));
192+
], Arr::remove($array, 'test.0'));
193193

194194
$this->assertSame([
195195
'test' => [
@@ -201,7 +201,7 @@ public function testUnset()
201201
'test6' => 'def'
202202
],
203203
],
204-
], Arr::unset($array, 'test.test2.test3'));
204+
], Arr::remove($array, 'test.test2.test3'));
205205

206206
$this->assertSame([
207207
'test' => [
@@ -212,13 +212,13 @@ public function testUnset()
212212
],
213213
[],
214214
],
215-
], Arr::unset($array, 'test.1.test6'));
215+
], Arr::remove($array, 'test.1.test6'));
216216

217-
$this->assertSame($array, Arr::unset($array, '0'));
218-
$this->assertSame($array, Arr::unset($array, 'test.test1'));
219-
$this->assertSame($array, Arr::unset($array, 'test.test2.test4'));
220-
$this->assertSame($array, Arr::unset($array, 'test.test2.test4.test5.test6.abc'));
221-
$this->assertSame($array, Arr::unset($array, 'test.2'));
217+
$this->assertSame($array, Arr::remove($array, '0'));
218+
$this->assertSame($array, Arr::remove($array, 'test.test1'));
219+
$this->assertSame($array, Arr::remove($array, 'test.test2.test4'));
220+
$this->assertSame($array, Arr::remove($array, 'test.test2.test4.test5.test6.abc'));
221+
$this->assertSame($array, Arr::remove($array, 'test.2'));
222222
}
223223

224224
public function testPack()

0 commit comments

Comments
 (0)