-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathNumRangeValue.php
More file actions
40 lines (33 loc) · 1.15 KB
/
Copy pathNumRangeValue.php
File metadata and controls
40 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
namespace Yiisoft\Db\Pgsql\Expression;
use RuntimeException;
use Yiisoft\Db\Expression\ExpressionInterface;
final class NumRangeValue implements ExpressionInterface
{
public function __construct(
public readonly int|float|null $lower = null,
public readonly int|float|null $upper = null,
public readonly bool $includeLower = true,
public readonly bool $includeUpper = true,
) {}
/**
* Returns the lower and upper bounds of a range, inclusive.
*
* @psalm-return array{0: int|float|null, 1: int|float|null}
*/
public function getBounds(): array
{
$lower = $this->lower === null || $this->includeLower
? $this->lower
: throw new RuntimeException(
'Lower bound cannot be determined from the excluded value of a numeric range.',
);
$upper = $this->upper === null || $this->includeUpper
? $this->upper
: throw new RuntimeException(
'Upper bound cannot be determined from the excluded value of a numeric range.',
);
return [$lower, $upper];
}
}