Completed
Push — master ( d015d4...c50906 )
by Mikołaj
02:42
created

ThemeConfigEditor::save()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 13
rs 9.4285
1
<?php
2
3
namespace Rudolf\Modules\Appearance\Change;
4
5
class ThemeConfigEditor
6
{
7
    /**
8
     * @var array
9
     */
10
    private $site;
11
12
    public function __construct()
13
    {
14
        $this->refresh();
15
    }
16
17
    public function refresh()
18
    {
19
        $this->site = include CONFIG_ROOT.'/site.php';
20
    }
21
22
    public function save()
23
    {
24
        $var_str = var_export($this->site, true);
25
        $var = "<?php return $var_str;\n";
26
27
        file_put_contents(CONFIG_ROOT.'/site.php', $var);
28
29
        if (function_exists('opcache_reset')) {
30
            opcache_reset();
31
        }
32
33
        $this->refresh();
34
    }
35
36
    /**
37
     * Activate non-active site.
38
     *
39
     * @param string $name module name
40
     */
41
    public function setThemeName($name)
42
    {
43
        $this->site['front_theme'] = $name;
44
    }
45
}
46