Skip to content

Commit 1f2de51

Browse files
committed
Refactor to utilize collections.
1 parent 8e2d302 commit 1f2de51

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/Console/ListCommand.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Jaspaul\LaravelRollout\Console;
44

5+
use Illuminate\Support\Collection;
56
use Jaspaul\LaravelRollout\FeaturePresenter;
67

78
class ListCommand extends RolloutCommand
@@ -23,22 +24,17 @@ class ListCommand extends RolloutCommand
2324
/**
2425
* Returns the feature rows.
2526
*
26-
* @return array
27+
* @return \Illuminate\Support\Collection
2728
* A list of features.
2829
*/
29-
protected function getRows() : array
30+
protected function getRows() : Collection
3031
{
31-
$rows = [];
32-
33-
$features = $this->rollout->features();
34-
35-
foreach ($features as $name)
36-
{
37-
$feature = new FeaturePresenter($this->rollout->get($name));
38-
$rows[] = $feature->toArray();
39-
}
40-
41-
return $rows;
32+
return (new Collection($this->rollout->features()))
33+
->map(function ($feature) {
34+
return new FeaturePresenter($this->rollout->get($feature));
35+
})->map(function (FeaturePresenter $feature) {
36+
return $feature->toArray();
37+
});
4238
}
4339

4440
/**

0 commit comments

Comments
 (0)