ServiceOptions   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createFromOptions() 0 4 1
A getAttemptsThreshold() 0 4 1
A getAttemptsTtl() 0 4 1
A getFailureTtl() 0 4 1
1
<?php
2
3
namespace FrancescoMalatesta\LaravelCircuitBreaker\Service;
4
5
final class ServiceOptions
6
{
7
    /** @var int */
8
    private $attemptsThreshold;
9
10
    /** @var int */
11
    private $attemptsTtl;
12
13
    /** @var int */
14
    private $failureTtl;
15
16
    /**
17
     * ServiceOptions constructor.
18
     *
19
     * @param $attemptsThreshold
20
     * @param $attemptsTtl
21
     * @param $failureTtl
22
     */
23
    private function __construct(int $attemptsThreshold, int $attemptsTtl, int $failureTtl)
24
    {
25
        $this->attemptsThreshold = $attemptsThreshold;
26
        $this->attemptsTtl = $attemptsTtl;
27
        $this->failureTtl = $failureTtl;
28
    }
29
30
    public static function createFromOptions($attemptsThreshold, $attemptsTtl, $failureTtl) : ServiceOptions
31
    {
32
        return new self($attemptsThreshold, $attemptsTtl, $failureTtl);
33
    }
34
35
    /**
36
     * @return int
37
     */
38
    public function getAttemptsThreshold(): int
39
    {
40
        return $this->attemptsThreshold;
41
    }
42
43
    /**
44
     * @return int
45
     */
46
    public function getAttemptsTtl(): int
47
    {
48
        return $this->attemptsTtl;
49
    }
50
51
    /**
52
     * @return int
53
     */
54
    public function getFailureTtl(): int
55
    {
56
        return $this->failureTtl;
57
    }
58
}
59