Passed
Pull Request — master (#27)
by Keoghan
04:06 queued 01:19
created

Config::updateDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace App\Support\Dnsmasq;
4
5
use App\PorterLibrary;
6
use Illuminate\Filesystem\Filesystem;
7
8
class Config
9
{
10
    /** @var Filesystem */
11
    protected $files;
12
13
    /** @var PorterLibrary */
14
    private $porterLibrary;
15
16
    public function __construct(Filesystem $files, PorterLibrary $porterLibrary)
17
    {
18
        $this->files = $files;
19
        $this->porterLibrary = $porterLibrary;
20
    }
21
22
    public function updateDomain($from, $to)
23
    {
24
        $filePath = $this->porterLibrary->configPath().'/dnsmasq/dnsmasq.conf';
25
26
        $newConfig = preg_replace("/\/.{$from}\//", "/.{$to}/", file_get_contents($filePath));
27
28
        $this->files->put($filePath, $newConfig);
29
    }
30
}
31