PublishLog::abortCommandExecution()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Acacha\ForgePublish\Commands;
4
5
use Acacha\ForgePublish\Commands\Traits\ChecksEnv;
6
use Acacha\ForgePublish\Commands\Traits\RunsSSHCommands;
7
use Acacha\ForgePublish\Parser\ForgePublishRCParser;
8
use GuzzleHttp\Client;
9
use Illuminate\Console\Command;
10
11
/**
12
 * Class PublishLog.
13
 *
14
 * @package Acacha\ForgePublish\Commands
15
 */
16
class PublishLog extends Command
17
{
18
    use ChecksEnv,RunsSSHCommands;
19
20
    /**
21
     * The name and signature of the console command.
22
     *
23
     * @var string
24
     */
25
    protected $signature = 'publish:log {--server=} {--domain=}';
26
27
    /**
28
     * The console command description.
29
     *
30
     * @var string
31
     */
32
    protected $description = 'Show logs on server (or localhost)';
33
34
    /**
35
     * ForgePublishRCParser
36
     *
37
     * @var ForgePublishRCParser
38
     */
39
    protected $parser;
40
41
    /**
42
     * Forge server.
43
     *
44
     * @var String
45
     */
46
    protected $server;
47
48
    /**
49
     * Domain.
50
     *
51
     * @var String
52
     */
53
    protected $domain;
54
55
    /**
56
     * Guzzle http client.
57
     *
58
     * @var Client
59
     */
60
    protected $http;
61
62
    /**
63
     * Create a new command instance.
64
     *
65
     */
66
    public function __construct(ForgePublishRCParser $parser, Client $http)
67
    {
68
        parent::__construct();
69
        $this->http = $http;
70
        $this->parser = $parser;
71
    }
72
73
    /**
74
     * Execute the console command.
75
     *
76
     */
77
    public function handle()
78
    {
79
        $this->abortCommandExecution();
80
81
        $this->info("Connecting to server $this->server to see logs");
82
        $this->runSSH("tail -f $this->domain/storage/logs/laravel.log");
83
    }
84
85
    /**
86
     * Abort command execution.
87
     *
88
     */
89
    protected function abortCommandExecution()
90
    {
91
        $this->server = $this->checkEnv('server', 'ACACHA_FORGE_SERVER');
92
        $this->domain = $this->checkEnv('domain', 'ACACHA_FORGE_DOMAIN');
93
    }
94
}
95