1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace PhpLightning\Shared\Value; |
||
6 | |||
7 | final readonly class SendableRange |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
8 | { |
||
9 | /** @var int 100 Minimum in msat (sat/1000) */ |
||
10 | private const DEFAULT_MIN_SENDABLE_IN_MILLISATS = 100_000; |
||
11 | |||
12 | /** @var int 10 000 000 Maximum in msat (sat/1000) */ |
||
13 | private const DEFAULT_MAX_SENDABLE_IN_MILLISATS = 10_000_000_000; |
||
14 | |||
15 | 7 | private function __construct( |
|
16 | private int $min, |
||
17 | private int $max, |
||
18 | ) { |
||
19 | 7 | } |
|
20 | |||
21 | 2 | public static function default(): self |
|
22 | { |
||
23 | 2 | return self::withMinMax( |
|
24 | 2 | self::DEFAULT_MIN_SENDABLE_IN_MILLISATS, |
|
25 | 2 | self::DEFAULT_MAX_SENDABLE_IN_MILLISATS, |
|
26 | 2 | ); |
|
27 | } |
||
28 | |||
29 | 7 | public static function withMinMax(int $min, int $max): self |
|
30 | { |
||
31 | 7 | return new self($min, $max); |
|
32 | } |
||
33 | |||
34 | 4 | public function contains(int $amount): bool |
|
35 | { |
||
36 | 4 | return $amount >= $this->min |
|
37 | 4 | && $amount <= $this->max; |
|
38 | } |
||
39 | |||
40 | 2 | public function min(): int |
|
41 | { |
||
42 | 2 | return $this->min; |
|
43 | } |
||
44 | |||
45 | 2 | public function max(): int |
|
46 | { |
||
47 | 2 | return $this->max; |
|
48 | } |
||
49 | } |
||
50 |