Test Failed
Pull Request — master (#85)
by Keoghan
06:33
created

SiteConfBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 11
c 0
b 0
f 0
dl 0
loc 36
ccs 0
cts 14
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A destroy() 0 3 1
A __construct() 0 3 1
A build() 0 9 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
    public function __construct(Filesystem $files)
13
    {
14
        $this->files = $files;
15
    }
16
17
    /**
18
     * Build the nginx.conf file for a given site.
19
     *
20
     * @param \App\Models\Site $site
21
     *
22
     * @throws \Throwable
23
     */
24
    public function build(Site $site)
25
    {
26
        $this->files->put(
27
            $site->nginx_conf_path,
28
            view($site->nginx_conf_template)->with([
1 ignored issue
show
Bug introduced by
It seems like view($site->nginx_conf_t...rsion->safe))->render() can also be of type array; however, parameter $contents of Illuminate\Filesystem\Filesystem::put() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

28
            /** @scrutinizer ignore-type */ view($site->nginx_conf_template)->with([
Loading history...
29
                'site'    => $site->url,
30
                'name'    => $site->name,
31
                'version' => $site->php_version->safe,
32
            ])->render()
33
        );
34
    }
35
36
    /**
37
     * Destroy the nginx.conf conf for a given site.
38
     *
39
     * @param \App\Models\Site $site
40
     */
41
    public function destroy(Site $site)
42
    {
43
        $this->files->delete($site->nginx_conf_path);
44
    }
45
}
46