Passed
Pull Request — master (#23)
by Keoghan
02:43
created

Container   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 17
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A updateDomain() 0 7 1
A __construct() 0 3 1
1
<?php
2
3
namespace App\Support\Dnsmasq;
4
5
use App\PorterLibrary;
6
use Illuminate\Filesystem\Filesystem;
7
8
class Container
9
{
10
    /** @var Filesystem */
11
    protected $files;
12
13
    public function __construct(Filesystem $files)
14
    {
15
        $this->files = $files;
16
    }
17
18
    public function updateDomain($from, $to)
19
    {
20
        $filePath = app(PorterLibrary::class)->configPath().'/dnsmasq/dnsmasq.conf';
21
22
        $newConfig = preg_replace("/\/.{$from}\//", "/.{$to}/", file_get_contents($filePath));
23
24
        $this->files->put($filePath, $newConfig);
25
    }
26
}
27