Completed
Push — master ( 8c3306...57acb7 )
by Martijn van
02:51
created

ProtectSuperSakeCommand::writehtaccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
4
class ProtectSuperSakeCommand extends SilverstripeCommand
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
5
{
6
    /**
7
     * @var string
8
     */
9
    protected $name = 'console:protect';
10
11
    /**
12
     * @var string
13
     */
14
    protected $description = 'Prevent direct file access by .htaccess and web.config';
15
16
    public function fire()
17
    {
18
        // $this->writeHtAccessFile();
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
19
    }
20
21
    /**
22
     * protect the supersake file with htaccess.
23
     */
24
    protected function writehtaccess()
25
    {
26
        $content = '# Deny access to supersake
0 ignored issues
show
Unused Code introduced by
$content is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
27
<Files supersake>
28
	Order allow,deny
29
	Deny from all
30
</Files>';
31
    }
32
33
    /**
34
     * protect the supersake file with web.config.
35
     */
36
    public function writewebconfig()
37
    {
38
        //<add fileExtension="supersake" allowed="false"/>
39
    }
40
}
41