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

Container::updateDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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