Completed
Push — bugfix/remove-usage-of-mopa-bo... ( dec083...82d2d0 )
by
unknown
01:57
created

Connection::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Surfnet\StepupGateway\Behat\Repository;
4
5
use Doctrine\DBAL\Connection as DBALConnection;
6
use Exception;
7
use PDO;
8
use PDOStatement;
9
10
class Connection
11
{
12
    /**
13
     * @var PDO
14
     */
15
    private $connection;
16
17
    /**
18
     * @param DBALConnection $connection
19
     * @throws Exception
20
     */
21
    public function __construct(DBALConnection $connection)
22
    {
23
        $conn = $connection->getWrappedConnection();
24
        if (!$conn instanceof PDO) {
25
            throw new Exception('DBAL Connection should be wrapped around PDO connection');
26
        }
27
28
        $this->connection = $conn;
29
    }
30
31
    /**
32
     * @param string $statement
33
     * @return bool|PDOStatement
34
     */
35
    public function prepare($statement)
36
    {
37
        return $this->connection->prepare($statement);
38
    }
39
}
40