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

RenewCertificates   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 33
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 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