GoOnline::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 13
rs 9.9666
1
<?php
2
3
namespace Sunnysideup\UnderConstruction\Tasks;
4
5
class GoOnline extends GoOffline
6
{
7
    protected $title = 'Go Online / End Under Construction Period';
8
9
    private static $segment = 'go-online-or-finish-construction';
10
11
    /**
12
     * @param \SilverStripe\Control\HTTPRequest $request
13
     * @throws \ReflectionException
14
     */
15
    public function run($request)
16
    {
17
        $path = $this->getHtAccessPath();
18
        $currentContent = file_get_contents($path);
19
        $contentToRemove = $this->getHtAccessContent();
20
        if (strpos($currentContent, $contentToRemove) !== false) {
21
            $currentContent = str_replace($contentToRemove, '', $currentContent);
22
            $currentContent = str_replace($contentToRemove, '', $currentContent);
23
            $currentContent = str_replace($contentToRemove, '', $currentContent);
24
        }
25
        file_put_contents($path, $currentContent);
26
27
        return 'Your site is now offline.';
28
    }
29
}
30