NotProcessableException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 2
cbo 0
dl 0
loc 60
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A maxTries() 0 6 1
A retryProgressively() 0 7 1
A getSecondsBeforeRetry() 0 4 1
A getMaxTries() 0 4 1
A getProgressionMultiplier() 0 4 1
1
<?php
2
3
namespace hiapi\exceptions;
4
5
/**
6
 * Class NotProcessableException
7
 *
8
 * @author Dmytro Naumenko <[email protected]>
9
 */
10
class NotProcessableException extends \RuntimeException
11
{
12
    /**
13
     * @var int
14
     */
15
    protected $progressionMultiplier = 1;
16
    /**
17
     * @var int
18
     */
19
    private $secondsBeforeRetry;
20
21
    /**
22
     * @var int
23
     */
24
    private $maxTries;
25
26
    public function maxTries(int $maxTries): NotProcessableException
27
    {
28
        $this->maxTries = $maxTries;
29
30
        return $this;
31
    }
32
33
    /**
34
     * @param $delaySeconds
35
     * @param float $progressionMultiplier
36
     * @return self
37
     */
38
    public function retryProgressively($delaySeconds, $progressionMultiplier): NotProcessableException
39
    {
40
        $this->secondsBeforeRetry = $delaySeconds;
41
        $this->progressionMultiplier = $progressionMultiplier;
0 ignored issues
show
Documentation Bug introduced by
The property $progressionMultiplier was declared of type integer, but $progressionMultiplier is of type double. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
42
43
        return $this;
44
    }
45
46
    /**
47
     * @return int
48
     */
49
    public function getSecondsBeforeRetry(): ?int
50
    {
51
        return $this->secondsBeforeRetry;
52
    }
53
54
    /**
55
     * @return int
56
     */
57
    public function getMaxTries(): ?int
58
    {
59
        return $this->maxTries;
60
    }
61
62
    /**
63
     * @return int
64
     */
65
    public function getProgressionMultiplier(): int
66
    {
67
        return $this->progressionMultiplier;
68
    }
69
}
70