FailSafe   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 51
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A with() 0 16 3
A and() 0 4 1
A run() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace Aguimaraes\Bureaucrat;
4
5
class FailSafe
6
{
7
    /**
8
     * @var CircuitBreaker
9
     */
10
    private $circuitBreaker;
11
12
    /**
13
     * @var Retry
14
     */
15
    private $retry;
16
17
    /**
18
     * @param $policy
19
     *
20
     * @return FailSafe
21
     * @throws \InvalidArgumentException
22
     */
23
    public function with($policy) : FailSafe
24
    {
25
        if ($policy instanceof CircuitBreaker) {
26
            $this->circuitBreaker = $policy;
27
28
            return $this;
29
        }
30
31
        if ($policy instanceof Retry) {
32
            $this->retry = $policy;
33
34
            return $this;
35
        }
36
37
        throw new \InvalidArgumentException('Argument is an invalid policy');
38
    }
39
40
    /**
41
     * @param $policy
42
     *
43
     * @return FailSafe
44
     * @throws \InvalidArgumentException
45
     */
46
    public function and($policy) : FailSafe
47
    {
48
        return $this->with($policy);
49
    }
50
51
    public function run(callable $operation, array $args = [])
0 ignored issues
show
Unused Code introduced by
The parameter $operation is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    {
53
        // TODO
54
    }
55
}
56