Completed
Push — master ( 17c57a...8a23e4 )
by Sébastien
02:02
created

PdoMysqlAdapter::query()   B

Complexity

Conditions 5
Paths 11

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5.246

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
ccs 11
cts 14
cp 0.7857
rs 8.8571
cc 5
eloc 14
nc 11
nop 1
crap 5.246
1
<?php
2
3
namespace Soluble\DbWrapper\Adapter;
4
5
use Soluble\DbWrapper\Exception;
6
use Soluble\DbWrapper\Adapter\Pdo\GenericPdo;
7
use PDO;
8
9
class PdoMysqlAdapter extends GenericPdo implements AdapterInterface
10
{
11
    use Mysql\MysqlCommonTrait;
12
13
    /**
14
     *
15
     * @var \PDO
16
     */
17
    protected $resource;
18
19
20
    /**
21
     * Constructor
22
     *
23
     * @throws Exception\InvalidArgumentException
24
     * @param \PDO $connection
25
     */
26 6
    public function __construct(PDO $connection)
27
    {
28 6
        if ($connection->getAttribute(\PDO::ATTR_DRIVER_NAME) != 'mysql') {
29
            $msg = __CLASS__ . " requires pdo connection to be 'mysql'";
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
30
        }
31 6
        $this->resource = $connection;
32 6
    }
33
}
34