Completed
Push — master ( 88de30...a4b642 )
by Martijn van
02:12
created

DefaultCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
use Symfony\Component\Console\Command\ListCommand;
4
use Symfony\Component\Console\Input\InputInterface;
5
use Symfony\Component\Console\Output\OutputInterface;
6
7
/**
8
 * Class SilverstripeListCommand
9
 *
10
 * We really need NameSpaces in Silverstripe....
11
 */
12
class DefaultCommand extends ListCommand
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...
13
{
14
15
    protected function execute(InputInterface $input, OutputInterface $output)
16
    {
17
        parent::execute($input, $output);
18
19
        $this->addProtectionWarningToOutput($output);
20
    }
21
22
    /**
23
     * @return bool|string
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
24
     */
25
    public function addProtectionWarningToOutput(OutputInterface $output)
26
    {
27
        $checker =  new SuperSakeChecker();
28
        if((bool)$checker->superSakeIsNotProtected()) {
29
            $output->writeln("\n");
30
            $output->writeln('<error>The supersake file is accessible by browsers</error>');
31
            $output->writeln('<error>Please lock down the file by either : </error>');
32
            $output->writeln('<comment>Adding this to your .htaccess file</comment>');
33
            $output->writeln($checker->htaccessContent());
34
            $output->writeln('<comment>Or add this to the <fileExtensions allowUnlisted="true"> section of your web.config file if you are running on iis</comment>');
35
            $output->writeln($checker->webconfigContent());
36
            $output->writeln("\n");
37
        }
38
    }
39
40
}
41