Passed
Push — master ( 4fbc87...0ba952 )
by Keoghan
03:33
created

RenewCertificates::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace App\Commands\Site;
4
5
use App\Commands\BaseCommand;
6
use App\Models\Site;
7
use App\Support\Ssl\CertificateBuilder;
8
9
class RenewCertificates extends BaseCommand
10
{
11
    /**
12
     * The signature of the command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'site:renew-certs {--clear-ca}';
17
18
    /**
19
     * The description of the command.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Renew certificates';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return void
29
     */
30 2
    public function handle(): void
31
    {
32
        /** @var CertificateBuilder $builder */
33 2
        $builder = app(CertificateBuilder::class);
34 2
        $builder->clearCertificates((bool) $this->option('clear-ca'));
35
36
        // The porter_default certificate is used for serving error pages
37
        // when a domain has not been set up in Porter
38 2
        $builder->build('porter_default');
39
40 2
        foreach (Site::where('secure', true)->get() as $site) {
41 1
            $site->buildCertificate();
42
        }
43 2
    }
44
}
45