src/Strategy/Delay/ArithmeticProgressionStrategy.php 1 location
|
@@ 9-29 (lines=21) @@
|
6 |
|
|
7 |
|
use DateInterval; |
8 |
|
|
9 |
|
class ArithmeticProgressionStrategy implements DelayStrategyInterface |
10 |
|
{ |
11 |
|
/** @var int */ |
12 |
|
private $startInterval; |
13 |
|
|
14 |
|
/** @var float */ |
15 |
|
private $multiplier; |
16 |
|
|
17 |
|
public function __construct(int $startIntervalSec, float $multiplier) |
18 |
|
{ |
19 |
|
$this->startInterval = $startIntervalSec; |
20 |
|
$this->multiplier = $multiplier; |
21 |
|
} |
22 |
|
|
23 |
|
public function generateInterval(int $iteration): DateInterval |
24 |
|
{ |
25 |
|
$newIntervalSec = (int) ceil($this->startInterval + ($this->multiplier * ($iteration - 1))); |
26 |
|
|
27 |
|
return new DateInterval('PT' . $newIntervalSec . 'S'); |
28 |
|
} |
29 |
|
} |
30 |
|
|
src/Strategy/Delay/GeometricProgressionStrategy.php 1 location
|
@@ 9-29 (lines=21) @@
|
6 |
|
|
7 |
|
use DateInterval; |
8 |
|
|
9 |
|
class GeometricProgressionStrategy implements DelayStrategyInterface |
10 |
|
{ |
11 |
|
/** @var int */ |
12 |
|
private $startInterval; |
13 |
|
|
14 |
|
/** @var float */ |
15 |
|
private $multiplier; |
16 |
|
|
17 |
|
public function __construct(int $startIntervalSec, float $multiplier) |
18 |
|
{ |
19 |
|
$this->startInterval = $startIntervalSec; |
20 |
|
$this->multiplier = $multiplier; |
21 |
|
} |
22 |
|
|
23 |
|
public function generateInterval(int $iteration): DateInterval |
24 |
|
{ |
25 |
|
$newIntervalSec = (int) ceil($this->startInterval * ($this->multiplier ** ($iteration - 1))); |
26 |
|
|
27 |
|
return new DateInterval('PT' . $newIntervalSec . 'S'); |
28 |
|
} |
29 |
|
} |
30 |
|
|