Factory::default()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 3
dl 0
loc 15
ccs 9
cts 9
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace JVelasco\CircuitBreaker;
4
5
use JVelasco\CircuitBreaker\Adapters\APCuStorage;
6
use JVelasco\CircuitBreaker\AvailabilityStrategy\Backoff\Exponential;
7
use JVelasco\CircuitBreaker\AvailabilityStrategy\TimeBackoff;
8
9
class Factory
10
{
11 1
    public static function default(
12
        int $maxFailures = 30,
13
        int $baseWaitTime = 20,
14
        int $maxWaitTime = 30000
15
    ): CircuitBreaker {
16 1
        $storage = new APCuStorage();
17 1
        $strategy = new TimeBackoff(
18 1
            $storage,
19 1
            new Exponential(),
20 1
            $maxFailures,
21 1
            $baseWaitTime,
22 1
            $maxWaitTime
23
        );
24
25 1
        return new CircuitBreaker($strategy, $storage);
26
    }
27
}
28