ServiceOptions::createFromOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
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