Skip to content

Commit fca7209

Browse files
authored
[12.x] Simpler and consistent Arr::collapse() (#56842)
* Simpler and consistent `Arr::collapse()` Removed the negation and `continue` as felt easier to read, consistent with other methods here. * Update Arr.php
1 parent cfaf85e commit fca7209

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Illuminate/Collections/Arr.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,10 @@ public static function collapse($array)
105105

106106
foreach ($array as $values) {
107107
if ($values instanceof Collection) {
108-
$values = $values->all();
109-
} elseif (! is_array($values)) {
110-
continue;
108+
$results[] = $values->all();
109+
} elseif (is_array($values)) {
110+
$results[] = $values;
111111
}
112-
113-
$results[] = $values;
114112
}
115113

116114
return array_merge([], ...$results);

0 commit comments

Comments
 (0)