Test Failed
Push — master ( 7fee35...e1add9 )
by Julien
24:19 queued 18:36
created

DatabaseTask::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 9
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 13
ccs 0
cts 10
cp 0
crap 2
rs 9.9666
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Modules\Cli\Tasks;
13
14
use Zemit\Bootstrap\Deployment;
15
use Zemit\Modules\Cli\Task;
16
use Zemit\Modules\Cli\Tasks\Traits\DatabaseTrait;
17
use Zemit\Utils;
18
19
class DatabaseTask extends Task
20
{
21
    use DatabaseTrait;
22
    
23
    public string $cliDoc = <<<DOC
24
Usage:
25
  php zemit cli database <action> [<params> ...]
26
27
Options:
28
  task: database
29
  action: drop, truncate, fixEngine, insert, optimize, analyze
30
31
32
DOC;
33
    
34
    public ?array $drop = null;
35
    public ?array $truncate = null;
36
    public ?array $engine = null;
37
    public ?array $insert = null;
38
    public ?array $optimize = null;
39
    public ?array $analyze = null;
40
    
41
    public function initialize(): void
42
    {
43
        Utils::setUnlimitedRuntime();
44
        
45
        $deploymentConfig = new Deployment();
46
        $this->drop ??= $deploymentConfig->pathToArray('drop');
47
        $this->truncate ??= $deploymentConfig->pathToArray('truncate');
48
        $this->engine ??= $deploymentConfig->pathToArray('engine');
49
        $this->insert ??= $deploymentConfig->pathToArray('insert');
50
        $this->optimize ??= $deploymentConfig->pathToArray('optimize');
51
        $this->analyze ??= $deploymentConfig->pathToArray('analyze');
52
        
53
        $this->addModelsPermissions();
54
    }
55
}
56