Failed Conditions
Push — master ( ac05b5...2858d3 )
by Keoghan
02:49
created

SiteConfBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace App\Support\Nginx;
4
5
use App\Models\Site;
6
use Illuminate\Filesystem\Filesystem;
7
8
class SiteConfBuilder
9
{
10
    protected $files;
11
12 8
    public function __construct(Filesystem $files)
13
    {
14 8
        $this->files = $files;
15 8
    }
16
17
    /**
18
     * Build the nginx.conf file for a given site
19
     *
20
     * @param \App\Models\Site $site
21
     * @throws \Throwable
22
     */
23 1
    public function build(Site $site)
24
    {
25 1
        $this->files->put(
26 1
            $site->nginx_conf_path,
27 1
            view($site->nginx_conf_template)->with([
28 1
                'site' => $site->url,
29 1
                'name' => $site->name,
30 1
                'version' => $site->php_version->safe
31 1
            ])->render()
32
        );
33 1
    }
34
35
    /**
36
     * Destroy the nginx.conf conf for a given site
37
     *
38
     * @param \App\Models\Site $site
39
     */
40
    public function destroy(Site $site)
41
    {
42
        $this->files->delete($site->nginx_conf_path);
43
    }
44
}
45