Completed
Pull Request — master (#3)
by Beniamin
02:54
created

PDOStatement   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 6
c 2
b 0
f 1
lcom 1
cbo 0
dl 0
loc 55
ccs 15
cts 15
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A bindValue() 0 6 1
A rowCount() 0 4 1
A execute() 0 6 1
A fetchScalar() 0 8 2
1
<?php
2
3
/**
4
 * This file is part of Phuria SQL Builder 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\QueryBuilder\Statement;
13
14
/**
15
 * @author Beniamin Jonatan Šimko <[email protected]>
16
 */
17
class PDOStatement implements StatementInterface
18
{
19
    /**
20
     * @var \PDOStatement $wrappedStatement
21
     */
22
    private $wrappedStatement;
23
24
    /**
25
     * @param \PDOStatement $statement
26
     */
27 4
    public function __construct(\PDOStatement $statement)
28
    {
29 4
        $this->wrappedStatement = $statement;
30 4
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35 3
    public function bindValue($parameter, $value)
36
    {
37 3
        $this->wrappedStatement->bindValue($parameter, $value);
38
39 3
        return $this;
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45 4
    public function rowCount()
46
    {
47 4
        return $this->wrappedStatement->rowCount();
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53 4
    public function execute()
54
    {
55 4
        $this->wrappedStatement->execute();
56
57 4
        return $this;
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63 3
    public function fetchScalar()
64
    {
65 3
        if (0 === $this->rowCount()) {
66 1
            return null;
67
        }
68
69 2
        return $this->wrappedStatement->fetch(\PDO::FETCH_COLUMN);
70
    }
71
}