RetryStrategyFactory::create()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 10
cc 4
nc 4
nop 2
crap 4
1
<?php
2
3
namespace Tarantool\JobQueue\Handler\RetryStrategy;
4
5
use Tarantool\JobQueue\JobBuilder\RetryStrategies;
6
7
class RetryStrategyFactory
8
{
9
    public function create(string $strategy, array $args = []): RetryStrategy
10
    {
11 3
        switch ($strategy) {
12
            case RetryStrategies::CONSTANT: return new ConstantRetryStrategy(...$args);
0 ignored issues
show
Bug introduced by
$args is expanded, but the parameter $interval of Tarantool\JobQueue\Handl...Strategy::__construct() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

12
            case RetryStrategies::CONSTANT: return new ConstantRetryStrategy(/** @scrutinizer ignore-type */ ...$args);
Loading history...
13
            case RetryStrategies::EXPONENTIAL: return new ExponentialRetryStrategy(...$args);
0 ignored issues
show
Bug introduced by
$args is expanded, but the parameter $base of Tarantool\JobQueue\Handl...Strategy::__construct() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

13
            case RetryStrategies::EXPONENTIAL: return new ExponentialRetryStrategy(/** @scrutinizer ignore-type */ ...$args);
Loading history...
14 3
            case RetryStrategies::LINEAR: return new LinearRetryStrategy(...$args);
0 ignored issues
show
Bug introduced by
$args is expanded, but the parameter $step of Tarantool\JobQueue\Handl...Strategy::__construct() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

14
            case RetryStrategies::LINEAR: return new LinearRetryStrategy(/** @scrutinizer ignore-type */ ...$args);
Loading history...
15 2
        }
16 1
17
        throw new \InvalidArgumentException(sprintf('Unknown retry strategy "%s".', $strategy));
18
    }
19
}
20