InstallShell   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 32
c 4
b 0
f 0
dl 0
loc 47
ccs 0
cts 32
cp 0
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A main() 0 44 4
1
<?php
0 ignored issues
show
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Class found in ".php" file; use ".inc" extension instead
Loading history...
Coding Style introduced by
This file is missing a doc comment.
Loading history...
Coding Style introduced by
Header blocks must be separated by a single blank line
Loading history...
Coding Style introduced by
Filename "InstallShell.php" doesn't match the expected filename "installshell.php"
Loading history...
2
namespace App\Shell;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
use Cake\Console\Shell;
5
use Cake\Filesystem\Folder;
0 ignored issues
show
introduced by
Unused use statement
Loading history...
6
use Cake\Filesystem\File;
7
use Cake\Core\Configure;
8
use Cake\Core\Configure\Engine\PhpConfig;
0 ignored issues
show
introduced by
Unused use statement
Loading history...
9
10
class InstallShell extends Shell
0 ignored issues
show
Deprecated Code introduced by
The class Cake\Console\Shell has been deprecated: 3.6.0 ShellDispatcher and Shell will be removed in 5.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

10
class InstallShell extends /** @scrutinizer ignore-deprecated */ Shell
Loading history...
introduced by
Missing class doc comment
Loading history...
Coding Style Documentation introduced by
Missing doc comment for class InstallShell
Loading history...
11
{	
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
Coding Style introduced by
Opening brace should be on the same line as the declaration for class InstallShell
Loading history...
Coding Style introduced by
Opening class brace must be on a line by itself
Loading history...
12
13
    public function main()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function main()
Loading history...
introduced by
Missing function doc comment
Loading history...
14
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
15
        $this->out('FortuneCookies installation');
16
        $this->hr();
17
        $this->out('This procedure will output a file called app_local.php');
18
        $this->out('to store Security Salt and Database connection information');
19
		
20
        // Salt
0 ignored issues
show
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
21
        $this->hr();
22
        $this->out('Configure Security Salt');
23
        $this->out('A Security Salt is a random string used to encrypt sensitive data inside this app.');
24
        $salt = $this->in('Type a string:');
25
        Configure::write('Security.salt', $salt);
26
        // Database\Connection
27
        // Admin account
28
        // Mail
0 ignored issues
show
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
introduced by
There must be no blank line following an inline comment
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
29
		
30
        if(!Configure::read('Security.salt'))
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
introduced by
Expected 1 space after closing parenthesis; found 9
Loading history...
introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
Coding Style introduced by
Expected "if (...) {\n"; found "if(...)\n {\n"
Loading history...
Coding Style introduced by
Expected 1 space(s) after IF keyword; 0 found
Loading history...
Coding Style introduced by
There must be a single space between the closing parenthesis and the opening brace of a multi-line IF statement; found newline
Loading history...
31
        {
32
            $salt = $this->in('Salt:');
0 ignored issues
show
Unused Code introduced by
The assignment to $salt is dead and can be removed.
Loading history...
33
        }
34
35
        Configure::write('debug', false);
36
        Configure::write('Datasources.default.className', 'Cake\Database\Connection');
37
        Configure::write('Datasources.default.driver', 'Cake\Database\Driver\Mysql');
38
        Configure::write('Datasources.default.persistent', false);
39
        Configure::write('Datasources.default.host', 'localhost');
40
        Configure::write('Datasources.default.username', 'root');
41
        Configure::write('Datasources.default.password', 'semaphoredb');
42
        Configure::write('Datasources.default.database', 'fc_test');
43
        Configure::write('Datasources.default.encoding', 'utf8');
44
        Configure::write('Datasources.default.timezone', 'UTC');
45
        Configure::write('Datasources.default.flags', []);
46
        Configure::write('Datasources.default.cacheMetadata', true);
47
        Configure::write('Datasources.default.log', false);
48
        Configure::write('Datasources.default.quoteIdentifiers', false);
49
        Configure::write('Datasources.default.url', env('DATABASE_URL', null));
50
        $file = new File('config/app_local.php', false);
0 ignored issues
show
Deprecated Code introduced by
The class Cake\Filesystem\File has been deprecated: 4.0.0 Will be removed in 5.0. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

50
        $file = /** @scrutinizer ignore-deprecated */ new File('config/app_local.php', false);
Loading history...
51
        if(!$file->exists()) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
Coding Style introduced by
Expected 1 space(s) after IF keyword; 0 found
Loading history...
52
            if($ris = Configure::dump('app_local', 'default')) {
0 ignored issues
show
Unused Code introduced by
The assignment to $ris is dead and can be removed.
Loading history...
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
Coding Style introduced by
Variable assignment found within a condition. Did you mean to do a comparison ?
Loading history...
Coding Style introduced by
Assignments must be the first block of code on a line
Loading history...
Coding Style introduced by
Expected 1 space(s) after IF keyword; 0 found
Loading history...
53
                $this->out("Wrote config file app_local.php");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Wrote config file app_local.php does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
54
            }
55
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
56
        $file->close();
57
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 0 found
Loading history...
58
}
59