Failed Conditions
Pull Request — master (#32)
by Mathieu
02:59
created

CallAndRetry::context()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Ez\DbLinker\Driver\Connection;
4
5
use Exception;
6
use Ez\DbLinker\RetryStrategy;
7
8
trait CallAndRetry
9
{
10
    /**
11
     * call $callable and retry if necessary
12
     * @param  string $method    method name
0 ignored issues
show
Bug introduced by
There is no parameter named $method. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
13
     * @param  array  $arguments [description]
0 ignored issues
show
Bug introduced by
There is no parameter named $arguments. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
14
     */
15
    private function callAndRetry(callable $callable, RetryStrategy $strategy)
16
    {
17
        do {
18
            try {
19
                return @$callable();
20
            } catch (Exception $exception) {
21
                if (!$strategy->shouldRetry(
22
                    $exception,
23
                    $callable,
24
                    $this->context()
25
                )) {
26
                    // stop trying
27
                    throw $exception;
28
                }
29
            }
30
        } while (true);
31
    }
32
33
    private function context()
34
    {
35
        return $this;
36
    }
37
}
38