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

SiteConfBuilder::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 9
ccs 0
cts 8
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
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