Completed
Pull Request — feature/acceptance-tests (#192)
by
unknown
03:32 queued 01:52
created

Connection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 2
A prepare() 0 4 1
1
<?php
2
3
namespace Surfnet\StepupGateway\Behat\Repository;
4
5
use Doctrine\DBAL\Connection as DBALConnection;
6
use PDO;
7
use PDOStatement;
8
9
class Connection
10
{
11
    /**
12
     * @var PDO
13
     */
14
    private $connection;
15
16
    /**
17
     * @param DBALConnection $connection
18
     * @throws \Exception
19
     */
20
    public function __construct(DBALConnection $connection)
21
    {
22
        var_dump([
0 ignored issues
show
Security Debugging Code introduced by
var_dump(array('host' =>...ction->getPassword())); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
23
            'host' => $connection->getHost(),
24
            'port' => $connection->getPort(),
25
            'dbname' => $connection->getDatabase(),
26
            'user' => $connection->getUsername(),
27
            'pass' => $connection->getPassword(),
28
        ]);
29
        $connection->connect();
30
        $conn = $connection->getWrappedConnection();
31
        if (!$conn instanceof PDO) {
32
            throw new \Exception('DBAL Connection should be wrapped around PDO connection');
33
        }
34
35
        $this->connection = $conn;
36
    }
37
38
    /**
39
     * @param string $statement
40
     * @return bool|PDOStatement
41
     */
42
    public function prepare($statement)
43
    {
44
        return $this->connection->prepare($statement);
45
    }
46
}
47