GoOnline   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 13 2
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