DefaultCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
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
    protected function execute(InputInterface $input, OutputInterface $output)
15
    {
16
        parent::execute($input, $output);
17
18
        $this->addProtectionWarningToOutput($output);
19
    }
20
21
    /**
22
     * @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...
23
     */
24
    public function addProtectionWarningToOutput(OutputInterface $output)
25
    {
26
        $checker = new SuperSakeChecker();
27
        if ((bool) $checker->superSakeIsNotProtected()) {
28
            $output->writeln("\n");
29
            $output->writeln('<error>The supersake file is accessible by browsers</error>');
30
            $output->writeln('<error>Please lock down the file by either : </error>');
31
            $output->writeln('<comment>Adding this to your .htaccess file</comment>');
32
            $output->writeln($checker->htaccessContent());
33
            $output->writeln('<comment>Or add this to the <fileExtensions allowUnlisted="true"> section of your web.config file if you are running on iis</comment>');
34
            $output->writeln($checker->webconfigContent());
35
            $output->writeln("\n");
36
            $output->writeln('<comment>Or run $ `php supersake protect` to write these lines to the files</comment>');
37
            $output->writeln("\n");
38
        }
39
    }
40
}
41