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

PdoMysqlAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 25
wmc 2
lcom 0
cbo 2
ccs 4
cts 6
cp 0.6667
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
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