Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 2c05727

Browse files
committed
cleanup
1 parent cae6c65 commit 2c05727

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

src/Traits/HelpsLoopFunctions.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,6 @@ private function ignoreKeys(): array
4040
: $defaults;
4141
}
4242

43-
/**
44-
* Check if the function can walk recursively over an array.
45-
*
46-
* @param mixed $value
47-
* @param int|string $key
48-
*
49-
* @return bool
50-
*/
51-
private function canWalkRecursively(mixed $value, int|string $key): bool
52-
{
53-
return is_array($value) && ! empty($this->{$key});
54-
}
55-
5643
/**
5744
* @param int|string $key
5845
*

src/Traits/LoopFunctions.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ public function arrayToProperties(?array $data, mixed $rescue = null): void
6161
{
6262
collect($data ?? [])
6363
->except($this->ignoreKeys())
64-
->each(function ($value, $key) use ($rescue) {
65-
if ($this->canWalkRecursively($value, $key)) {
66-
$this->arrayToProperties($value, $rescue);
67-
}
68-
69-
$this->assignValue($key, $value, $rescue);
70-
});
64+
->each(fn ($value, $key) => $this->assignValue($key, $value, $rescue));
7165
}
7266
}

tests/ArrayMappingTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testCanMapAnArrayToProperties()
3535
}
3636

3737
/** @test */
38-
public function testCanMapAnArrayRecursively()
38+
public function testCanMapAnArray()
3939
{
4040
$array = [
4141
'test' => true,
@@ -64,6 +64,7 @@ public function testAlreadyInitializedPropertiesArentOverridenByNestedArrays()
6464
],
6565
];
6666

67+
6768
$this->arrayToProperties($array);
6869

6970
$this->assertStringContainsString('Michael', $this->name);
@@ -108,7 +109,9 @@ public function testCanMapUsingPropertiesFrom()
108109
$array = [
109110
'test' => true,
110111
'additional_data' => [
111-
'next' => 'test',
112+
'next' => [
113+
'test' => true,
114+
],
112115
],
113116
];
114117

0 commit comments

Comments
 (0)