Passed
Branch master (44bfae)
by giu
03:41
created

InstallShell   A

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
2
namespace App\Shell;
3
4
use Cake\Console\Shell;
5
use Cake\Filesystem\Folder;
6
use Cake\Filesystem\File;
7
use Cake\Core\Configure;
8
use Cake\Core\Configure\Engine\PhpConfig;
9
10
class InstallShell extends Shell
11
{	
0 ignored issues
show
Coding Style introduced by
The opening class brace should be on a newline by itself.
Loading history...
12
13
    public function main()
14
    {
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
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
29
		
30
        if(!Configure::read('Security.salt'))
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);
51
        if(!$file->exists()) {
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...
53
                $this->out("Wrote config file app_local.php");
54
            }
55
        }
56
        $file->close();
57
    }
58
}
59