Code Duplication    Length = 74-75 lines in 4 locations

src/Console/Commands/PublishArtisan.php 1 location

@@ 15-88 (lines=74) @@
12
 *
13
 * @package Acacha\ForgePublish\Commands
14
 */
15
class PublishArtisan extends Command
16
{
17
    use ChecksEnv, RunsSSHCommands;
18
19
    /**
20
     * Server name
21
     *
22
     * @var String
23
     */
24
    protected $server;
25
26
    /**
27
     * Domain
28
     *
29
     * @var String
30
     */
31
    protected $domain;
32
33
    /**
34
     * The name and signature of the console command.
35
     *
36
     * @var string
37
     */
38
    protected $signature = 'publish:artisan {artisan_command?} {--server=} {--domain=}';
39
40
    /**
41
     * The console command description.
42
     *
43
     * @var string
44
     */
45
    protected $description = 'Run artisan on production server';
46
47
    /**
48
     * Guzzle http client.
49
     *
50
     * @var Client
51
     */
52
    protected $http;
53
54
    /**
55
     * Create a new command instance.
56
     *
57
     */
58
    public function __construct(Client $http)
59
    {
60
        parent::__construct();
61
        $this->http = $http;
62
    }
63
64
    /**
65
     * Execute the console command.
66
     *
67
     */
68
    public function handle()
69
    {
70
        $this->abortCommandExecution();
71
        $command = $this->argument('artisan_command');
72
        $this->info("Running php artisan $command on production...");
73
        $this->runSSH("cd $this->domain;php artisan $command");
74
    }
75
76
    /**
77
     * Abort command execution?
78
     */
79
    protected function abortCommandExecution()
80
    {
81
        $this->server = $this->checkEnv('server', 'ACACHA_FORGE_SERVER');
82
        $this->domain = $this->checkEnv('domain', 'ACACHA_FORGE_DOMAIN');
83
84
        $this->abortIfNoSSHConnection();
85
    }
86
}
87

src/Console/Commands/PublishComposer.php 1 location

@@ 15-89 (lines=75) @@
12
 *
13
 * @package Acacha\ForgePublish\Commands
14
 */
15
class PublishComposer extends Command
16
{
17
    use ChecksEnv, RunsSSHCommands;
18
19
    /**
20
     * Server name
21
     *
22
     * @var String
23
     */
24
    protected $server;
25
26
    /**
27
     * Domain
28
     *
29
     * @var String
30
     */
31
    protected $domain;
32
33
    /**
34
     * The name and signature of the console command.
35
     *
36
     * @var string
37
     */
38
    protected $signature = 'publish:composer {composer_command} {--server=} {--domain=}';
39
40
    /**
41
     * The console command description.
42
     *
43
     * @var string
44
     */
45
    protected $description = 'Run composer on production server';
46
47
    /**
48
     * Guzzle http client.
49
     *
50
     * @var Client
51
     */
52
    protected $http;
53
54
    /**
55
     * Create a new command instance.
56
     *
57
     */
58
    public function __construct(Client $http)
59
    {
60
        parent::__construct();
61
        $this->http = $http;
62
    }
63
64
    /**
65
     * Execute the console command.
66
     *
67
     */
68
    public function handle()
69
    {
70
        $this->abortCommandExecution();
71
        $command = $this->argument('composer_command');
72
        $this->info("Running composer $command on production...");
73
74
        $this->runSSH("cd $this->domain;composer $command");
75
    }
76
77
    /**
78
     * Abort command execution?
79
     */
80
    protected function abortCommandExecution()
81
    {
82
        $this->server = $this->checkEnv('server', 'ACACHA_FORGE_SERVER');
83
        $this->domain = $this->checkEnv('domain', 'ACACHA_FORGE_DOMAIN');
84
85
        $this->abortIfNoSSHConnection();
86
    }
87
}
88

src/Console/Commands/PublishGit.php 1 location

@@ 15-88 (lines=74) @@
12
 *
13
 * @package Acacha\ForgePublish\Commands
14
 */
15
class PublishGit extends Command
16
{
17
    use ChecksEnv, RunsSSHCommands;
18
19
    /**
20
     * Server name
21
     *
22
     * @var String
23
     */
24
    protected $server;
25
26
    /**
27
     * Domain
28
     *
29
     * @var String
30
     */
31
    protected $domain;
32
33
    /**
34
     * The name and signature of the console command.
35
     *
36
     * @var string
37
     */
38
    protected $signature = 'publish:git {git_command} {--server=} {--domain=}';
39
40
    /**
41
     * The console command description.
42
     *
43
     * @var string
44
     */
45
    protected $description = 'Execute git command on production';
46
47
    /**
48
     * Guzzle http client.
49
     *
50
     * @var Client
51
     */
52
    protected $http;
53
54
    /**
55
     * Create a new command instance.
56
     *
57
     */
58
    public function __construct(Client $http)
59
    {
60
        parent::__construct();
61
        $this->http = $http;
62
    }
63
64
    /**
65
     * Execute the console command.
66
     *
67
     */
68
    public function handle()
69
    {
70
        $this->abortCommandExecution();
71
        $command = $this->argument('git_command');
72
        $this->info("Running git $command on production...");
73
74
        $this->runSSH("cd $this->domain;git $command");
75
    }
76
77
    /**
78
     * Abort command execution?
79
     */
80
    protected function abortCommandExecution()
81
    {
82
        $this->server = $this->checkEnv('server', 'ACACHA_FORGE_SERVER');
83
        $this->domain = $this->checkEnv('domain', 'ACACHA_FORGE_DOMAIN');
84
85
        $this->abortIfNoSSHConnection();
86
    }
87
}
88

src/Console/Commands/PublishNpm.php 1 location

@@ 15-89 (lines=75) @@
12
 *
13
 * @package Acacha\ForgePublish\Commands
14
 */
15
class PublishNpm extends Command
16
{
17
    use ChecksEnv, RunsSSHCommands;
18
19
    /**
20
     * Server name
21
     *
22
     * @var String
23
     */
24
    protected $server;
25
26
    /**
27
     * Domain
28
     *
29
     * @var String
30
     */
31
    protected $domain;
32
33
    /**
34
     * The name and signature of the console command.
35
     *
36
     * @var string
37
     */
38
    protected $signature = 'publish:npm {npm_command} {--server=} {--domain=}';
39
40
    /**
41
     * The console command description.
42
     *
43
     * @var string
44
     */
45
    protected $description = 'Run npm on production server';
46
47
    /**
48
     * Guzzle http client.
49
     *
50
     * @var Client
51
     */
52
    protected $http;
53
54
    /**
55
     * Create a new command instance.
56
     *
57
     */
58
    public function __construct(Client $http)
59
    {
60
        parent::__construct();
61
        $this->http = $http;
62
    }
63
64
    /**
65
     * Execute the console command.
66
     *
67
     */
68
    public function handle()
69
    {
70
        $this->abortCommandExecution();
71
        $command = $this->argument('npm_command');
72
        $this->info("Running npm $command on production...");
73
74
        $this->runSSH("cd $this->domain;npm $command");
75
    }
76
77
    /**
78
     * Abort command execution?
79
     */
80
    protected function abortCommandExecution()
81
    {
82
        $this->server = $this->checkEnv('server', 'ACACHA_FORGE_SERVER');
83
        $this->domain = $this->checkEnv('domain', 'ACACHA_FORGE_DOMAIN');
84
85
        $this->abortIfNoSSHConnection();
86
    }
87
}
88