Completed
Push — master ( 76c4af...25f226 )
by Morgan
23:24
created

DeployInfoCommand::fire()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 20
ccs 12
cts 12
cp 1
rs 9.2
cc 4
eloc 13
nc 3
nop 0
crap 4
1
<?php
2
3
namespace Morphatic\AutoDeploy\Commands;
4
5
use Illuminate\Console\Command;
6
7
class DeployInfoCommand extends Command
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'deploy:info';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Display information necessary to set up Github webhook';
22
23
    /**
24
     * Execute the console command.
25
     */
26 2
    public function fire()
27
    {
28 2
        $path = base_path('.env');
29
        $message = 'You need to run `php artisan deploy:init` first.';
30 2
        if (file_exists($path)) {
31
            // get the contents of the .env file
32 1
            $env_content = file_get_contents($path);
0 ignored issues
show
Coding Style introduced by
$env_content does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
33
34
            // get the values of the two keys, and inform the user of the necessary information
35 1
            if (preg_match('/AUTODEPLOY_SECRET=(\S+)/', $env_content, $secret) &&
0 ignored issues
show
Coding Style introduced by
$env_content does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
36 1
                preg_match('/AUTODEPLOY_ROUTE=(\S+)/', $env_content, $route)) {
0 ignored issues
show
Coding Style introduced by
$env_content does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
37
                $url = parse_url(config('app.url'), PHP_URL_HOST);
38 1
                $message = "Here is the information you'll need to set up your webhook:\n\n".
39 1
                           "Payload URL: <comment>https://$url/{$route[1]}</comment>\n".
40
                           "Secret: <comment>{$secret[1]}</comment>\n\n".
41 1
                           "You can display this information again by running `php artisan deploy:info`\n";
42
            }
43 1
        }
44 1
        $this->info($message);
45 1
    }
46
}
47