Test Failed
Push — master ( 741545...e25e21 )
by Julien
11:23
created

Migration::fixDatabaseForPhalconScripts()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 12
ccs 0
cts 7
cp 0
rs 10
cc 3
nc 3
nop 0
crap 12
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 23 and the first side effect is on line 40.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Zemit\Config;
4
5
use Zemit\Bootstrap\Config;
6
7
/**
8
 * Class Config
9
 * Configuration collection extending the base config
10
 * Added a fix for the phalcon migration commands
11
 * Presetting the database driver and removing options
12
 *
13
 * {@inheritDoc}
14
 *
15
 * @author Julien Turbide <[email protected]>
16
 * @copyright Zemit Team <[email protected]>
17
 *
18
 * @since 1.0
19
 * @version 1.0
20
 *
21
 * @package App\Config
22
 */
23
class Migration extends Config
24
{
25
    /**
26
     * Migration constructor.
27
     * {@inheritDoc}
28
     *
29
     * @param array $config
30
     */
31
    public function __construct($config = [])
32
    {
33
        $config = parent::__construct($config);
0 ignored issues
show
Unused Code introduced by
The assignment to $config is dead and can be removed.
Loading history...
Bug introduced by
Are you sure the assignment to $config is correct as parent::__construct($config) targeting Zemit\Bootstrap\Config::__construct() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
34
        $this->database = $this->database->drivers->{$this->database->default};
0 ignored issues
show
Bug Best Practice introduced by
The property database does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35
        unset($this->database->options);
36
        unset($this->database->readOnly);
37
    }
38
}
39
40
return new Migration();
41