Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

MainChmodCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Apps\Console;
4
5
6
use Ffcms\Console\Command;
7
use Ffcms\Core\Helper\FileSystem\Directory;
8
use Ffcms\Core\Helper\FileSystem\File;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
/**
13
 * Class MainChmodCommand. Set chmods for default folders and files
14
 * @package Apps\Console
15
 */
16
class MainChmodCommand extends Command
17
{
18
    // dirs to create & chmod
19
    public static $installDirs = [
20
        '/upload/', '/upload/user/', '/upload/gallery/', '/upload/images/', '/upload/flash/', '/upload/files/', '/upload/sitemap/',
21
        '/Private/Cache/', '/Private/Cache/HTMLPurifier/', '/Private/Sessions/', '/Private/Antivirus/', '/Private/Install/', '/Private/Migrations/',
22
        '/Private/Config/', '/Private/Config/Default.php', '/Private/Config/Routing.php', '/Private/Config/Cron.php'
23
    ];
24
25
    /**
26
     * Set command binding & information
27
     */
28
    public function configure()
29
    {
30
        $this->setName('main:chmod')
31
            ->setDescription('Automatically set chmod\'s for default ffcms directorieswith read/write permissions');
32
            //->addOption('secure', 's', InputOption::VALUE_REQUIRED, 'Do you want to apply auto chmod with {0666|0776} permissions instead of 0777. Note you should make right chown & process user group. Answers: yes/no');
0 ignored issues
show
Unused Code Comprehensibility introduced by zenn
65% 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...
33
    }
34
35
    /**
36
     * Process change chmod for all dirs & files
37
     * @param InputInterface $input
38
     * @param OutputInterface $output
39
     * @return void
40
     */
41
    public function execute(InputInterface $input, OutputInterface $output)
42
    {
43
        //$secure = $input->getOption('secure');
0 ignored issues
show
Unused Code Comprehensibility introduced by zenn
64% 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...
44
        foreach (self::$installDirs as $obj) {
45
            if (Directory::exist($obj)) {
46
                Directory::recursiveChmod($obj, 0777);
47
                $output->writeln('Write recursive permissions 0777 for all directories in: ' . $obj);
48
            } elseif (File::exist($obj)) {
49
                chmod(root . $obj, 0777);
50
                $output->writeln('Write permissions 0777 for file: ' . $obj);
51
            }
52
        }
53
    }
54
}