Test Failed
Push — master ( 1fe578...f222e5 )
by Julien
05:09
created

DeploymentTask::insertAction()   B

Complexity

Conditions 10
Paths 28

Size

Total Lines 45
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 110

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 10
eloc 25
c 1
b 0
f 0
nc 28
nop 0
dl 0
loc 45
ccs 0
cts 25
cp 0
crap 110
rs 7.6666

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\DeploymentTrait;
17
use Zemit\Utils;
18
19
class DeploymentTask extends Task
20
{
21
    use DeploymentTrait;
22
    
23
    public string $cliDoc = <<<DOC
24
Usage:
25
  php zemit cli deployment <action> [<params> ...]
26
27
Options:
28
  task: cache
29
  action: clear
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
    
39
    public function initialize(): void
40
    {
41
        Utils::setUnlimitedRuntime();
42
        
43
        $deploymentConfig = new Deployment();
44
        $this->drop ??= $deploymentConfig->pathToArray('drop');
45
        $this->truncate ??= $deploymentConfig->pathToArray('truncate');
46
        $this->engine ??= $deploymentConfig->pathToArray('engine');
47
        $this->insert ??= $deploymentConfig->pathToArray('insert');
48
        
49
        $this->addModelsPermissions();
50
    }
51
}
52