Completed
Push — master ( 8fa5d0...315cf2 )
by Beniamin
06:27
created

PDOConnection::getWrappedConnection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of UnderQuery package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\UnderQuery\Connection;
13
14
use Phuria\UnderQuery\Statement\PDOStatement;
15
16
/**
17
 * @author Beniamin Jonatan Šimko <[email protected]>
18
 */
19
class PDOConnection implements ConnectionInterface
20
{
21
    /**
22
     * @var \PDO $wrappedConnection
23
     */
24
    private $wrappedConnection;
25
26
    /**
27
     * @param \PDO $connection
28
     */
29 3
    public function __construct(\PDO $connection)
30
    {
31 3
        $this->wrappedConnection = $connection;
32 3
    }
33
34
    /**
35
     * @return \PDO
36
     */
37 1
    public function getWrappedConnection()
38
    {
39 1
        return $this->wrappedConnection;
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45 2
    public function prepareStatement($SQL, $parameters = [])
46
    {
47 2
        $stmt = $this->wrappedConnection->prepare($SQL);
48 2
        $wrappedStatement = new PDOStatement($stmt);
49
50 2
        if ($parameters) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $parameters of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
51 1
            $wrappedStatement->bindParameters($parameters);
52 1
        }
53
54 2
        return $wrappedStatement;
55
    }
56
}