Completed
Push — master ( e02e4d...5773dd )
by
unknown
02:54 queued 11s
created

ArithmeticProgressionStrategy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 21
loc 21
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A generateInterval() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\QueueBundle\Strategy\Delay;
6
7
use DateInterval;
8
9 View Code Duplication
class ArithmeticProgressionStrategy implements DelayStrategyInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /** @var int */
12
    private $startInterval;
13
14
    /** @var float */
15
    private $multiplier;
16
17 8
    public function __construct(int $startIntervalSec, float $multiplier)
18
    {
19 8
        $this->startInterval = $startIntervalSec;
20 8
        $this->multiplier    = $multiplier;
21 8
    }
22
23 5
    public function generateInterval(int $iteration): DateInterval
24
    {
25 5
        $newIntervalSec = (int) ceil($this->startInterval + ($this->multiplier * ($iteration - 1)));
26
27 5
        return new DateInterval('PT' . $newIntervalSec . 'S');
28
    }
29
}
30