Skip to content

Commit 2528ba8

Browse files
committed
Refactor out a base rollout command
1 parent 8752732 commit 2528ba8

File tree

4 files changed

+40
-70
lines changed

4 files changed

+40
-70
lines changed

src/Console/AddUserCommand.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
namespace Jaspaul\LaravelRollout\Console;
44

5-
use Opensoft\Rollout\Rollout;
6-
use Illuminate\Console\Command;
75
use Jaspaul\LaravelRollout\Helpers\User;
86

9-
class AddUserCommand extends Command
7+
class AddUserCommand extends RolloutCommand
108
{
119
/**
1210
* The name and signature of the console command.
@@ -22,26 +20,6 @@ class AddUserCommand extends Command
2220
*/
2321
protected $description = 'Adds the provided user id to the feature.';
2422

25-
/**
26-
* The rollout service.
27-
*
28-
* @var \Opensoft\Rollout\Rollout
29-
*/
30-
protected $rollout;
31-
32-
/**
33-
* Initialize our create feature command with an instance of the rollout
34-
* service.
35-
*
36-
* @param \Opensoft\Rollout\Rollout $rollout
37-
* The rollout service.
38-
*/
39-
public function __construct(Rollout $rollout)
40-
{
41-
parent::__construct();
42-
$this->rollout = $rollout;
43-
}
44-
4523
/**
4624
* Creates the provided feature.
4725
*

src/Console/CreateCommand.php

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
namespace Jaspaul\LaravelRollout\Console;
44

5-
use Opensoft\Rollout\Rollout;
6-
use Illuminate\Console\Command;
7-
8-
class CreateCommand extends Command
5+
class CreateCommand extends RolloutCommand
96
{
107
/**
118
* The name and signature of the console command.
@@ -21,26 +18,6 @@ class CreateCommand extends Command
2118
*/
2219
protected $description = 'Creates a feature with the provided name.';
2320

24-
/**
25-
* The rollout service.
26-
*
27-
* @var \Opensoft\Rollout\Rollout
28-
*/
29-
protected $rollout;
30-
31-
/**
32-
* Initialize our create feature command with an instance of the rollout
33-
* service.
34-
*
35-
* @param \Opensoft\Rollout\Rollout $rollout
36-
* The rollout service.
37-
*/
38-
public function __construct(Rollout $rollout)
39-
{
40-
parent::__construct();
41-
$this->rollout = $rollout;
42-
}
43-
4421
/**
4522
* Creates the provided feature.
4623
*

src/Console/ListCommand.php

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
namespace Jaspaul\LaravelRollout\Console;
44

5-
use Opensoft\Rollout\Rollout;
6-
use Illuminate\Console\Command;
75
use Jaspaul\LaravelRollout\FeaturePresenter;
86

9-
class ListCommand extends Command
7+
class ListCommand extends RolloutCommand
108
{
119
/**
1210
* The name and signature of the console command.
@@ -22,32 +20,13 @@ class ListCommand extends Command
2220
*/
2321
protected $description = 'Returns a list of all the features that have been created.';
2422

25-
/**
26-
* The rollout service.
27-
*
28-
* @var \Opensoft\Rollout\Rollout
29-
*/
30-
protected $rollout;
31-
32-
/**
33-
* Initialize our list features command with an instance of the rollout service.
34-
*
35-
* @param \Opensoft\Rollout\Rollout $rollout
36-
* The rollout service.
37-
*/
38-
public function __construct(Rollout $rollout)
39-
{
40-
parent::__construct();
41-
$this->rollout = $rollout;
42-
}
43-
4423
/**
4524
* Returns the feature rows.
4625
*
4726
* @return array
4827
* A list of features.
4928
*/
50-
public function getRows() : array
29+
protected function getRows() : array
5130
{
5231
$rows = [];
5332

src/Console/RolloutCommand.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Jaspaul\LaravelRollout\Console;
4+
5+
use Opensoft\Rollout\Rollout;
6+
use Illuminate\Console\Command;
7+
8+
abstract class RolloutCommand extends Command
9+
{
10+
/**
11+
* The rollout service.
12+
*
13+
* @var \Opensoft\Rollout\Rollout
14+
*/
15+
protected $rollout;
16+
17+
/**
18+
* Initialize our create feature command with an instance of the rollout
19+
* service.
20+
*
21+
* @param \Opensoft\Rollout\Rollout $rollout
22+
* The rollout service.
23+
*/
24+
public function __construct(Rollout $rollout)
25+
{
26+
parent::__construct();
27+
$this->rollout = $rollout;
28+
}
29+
30+
/**
31+
* Performs the logic for the command.
32+
*
33+
* @return void
34+
*/
35+
abstract public function handle();
36+
}

0 commit comments

Comments
 (0)