Skip to content

Commit

Permalink
Refactor to utilize collections.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaspaul committed Mar 30, 2017
1 parent 8e2d302 commit 1f2de51
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/Console/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jaspaul\LaravelRollout\Console;

use Illuminate\Support\Collection;
use Jaspaul\LaravelRollout\FeaturePresenter;

class ListCommand extends RolloutCommand
Expand All @@ -23,22 +24,17 @@ class ListCommand extends RolloutCommand
/**
* Returns the feature rows.
*
* @return array
* @return \Illuminate\Support\Collection
* A list of features.
*/
protected function getRows() : array
protected function getRows() : Collection
{
$rows = [];

$features = $this->rollout->features();

foreach ($features as $name)
{
$feature = new FeaturePresenter($this->rollout->get($name));
$rows[] = $feature->toArray();
}

return $rows;
return (new Collection($this->rollout->features()))
->map(function ($feature) {
return new FeaturePresenter($this->rollout->get($feature));
})->map(function (FeaturePresenter $feature) {
return $feature->toArray();
});
}

/**
Expand Down

0 comments on commit 1f2de51

Please sign in to comment.