Passed
Pull Request — master (#27)
by Keoghan
03:38
created

Config   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 21
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A updateDomain() 0 7 1
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