RetryStatement   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 124
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 14
lcom 1
cbo 2
dl 0
loc 124
rs 10
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A execute() 0 6 1
A bindParam() 0 4 1
A bindValue() 0 4 1
A fetch() 0 4 1
A fetchAll() 0 4 1
A fetchColumn() 0 4 1
A errorCode() 0 4 1
A errorInfo() 0 4 1
A closeCursor() 0 4 1
A rowCount() 0 4 1
A columnCount() 0 4 1
A setFetchMode() 0 4 1
A getIterator() 0 4 1
1
<?php
2
3
namespace Ez\DbLinker\Driver\Connection;
4
5
use IteratorAggregate;
6
use Doctrine\DBAL\Driver\Statement;
7
use Ez\DbLinker\RetryStrategy;
8
9
class RetryStatement implements IteratorAggregate, Statement
10
{
11
    private $statement;
12
    private $retryConnection;
13
    private $retryStrategy;
14
15
    use CallAndRetry;
16
17
    /**
18
     * @param Statement $statement
19
     */
20
    public function __construct(Statement $statement, RetryConnection $retryConnection, RetryStrategy $retryStrategy)
21
    {
22
        $this->statement       = $statement;
23
        $this->retryConnection = $retryConnection;
24
        $this->retryStrategy   = $retryStrategy;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function execute($params = NULL)
31
    {
32
        return (bool)$this->callAndRetry(function () use ($params) {
33
            return $this->statement->execute($params);
0 ignored issues
show
Bug introduced by
It seems like $params defined by parameter $params on line 30 can also be of type array; however, Doctrine\DBAL\Driver\Statement::execute() does only seem to accept array<integer,*>|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
34
        }, $this->retryStrategy, $this->retryConnection);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function bindParam($column, &$variable, $type = null, $length = null)
41
    {
42
        return $this->statement->bindParam($column, $variable, $type, $length);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function bindValue($param, $value, $type = null)
49
    {
50
        return $this->statement->bindValue($param, $value, $type);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
57
    {
58
        return $this->statement->fetch($fetchMode, $cursorOrientation, $cursorOffset);
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
65
    {
66
        return $this->statement->fetchAll($fetchMode, $fetchArgument, $ctorArgs);
0 ignored issues
show
Bug introduced by
It seems like $ctorArgs defined by parameter $ctorArgs on line 64 can also be of type array; however, Doctrine\DBAL\Driver\ResultStatement::fetchAll() does only seem to accept array<integer,*>|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function fetchColumn($columnIndex = 0)
73
    {
74
        return $this->statement->fetchColumn($columnIndex);
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function errorCode()
81
    {
82
        return $this->statement->errorCode();
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function errorInfo()
89
    {
90
        return $this->statement->errorInfo();
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function closeCursor()
97
    {
98
        return $this->statement->closeCursor();
99
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104
    public function rowCount()
105
    {
106
        return $this->statement->rowCount();
107
    }
108
109
    /**
110
     * {@inheritdoc}
111
     */
112
    public function columnCount()
113
    {
114
        return $this->statement->columnCount();
115
    }
116
117
    /**
118
     * {@inheritdoc}
119
     */
120
    public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
121
    {
122
        return $this->statement->setFetchMode($fetchMode, $arg2, $arg3);
123
    }
124
125
    /**
126
     * {@inheritdoc}
127
     */
128
    public function getIterator()
129
    {
130
        return $this->statement;
131
    }
132
}
133