| Total Complexity | 9 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 5 | abstract class Range |
||
| 6 | { |
||
| 7 | protected string $fromBound; |
||
| 8 | protected string $toBound; |
||
| 9 | protected ?string $from; |
||
| 10 | protected ?string $to; |
||
| 11 | |||
| 12 | public function __construct(string $from = null, string $to = null, $fromBound = '[', $toBound = ')') |
||
| 13 | { |
||
| 14 | $this->from = $from; |
||
| 15 | $this->to = $to; |
||
| 16 | $this->fromBound = $fromBound; |
||
| 17 | $this->toBound = $toBound; |
||
| 18 | |||
| 19 | $this->checkForEmptyBoundaries(); |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @return mixed |
||
| 24 | */ |
||
| 25 | public function from() |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param string $boundary |
||
| 36 | * @return mixed |
||
| 37 | */ |
||
| 38 | abstract protected function transformBoundary(string $boundary); |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return mixed |
||
| 42 | */ |
||
| 43 | public function to() |
||
| 44 | { |
||
| 45 | if ($this->to === null) { |
||
| 46 | return; |
||
| 47 | } |
||
| 48 | |||
| 49 | return $this->transformBoundary($this->to); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | public function __toString() |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | abstract public function forSql(): string; |
||
| 64 | |||
| 65 | private function checkForEmptyBoundaries(): void |
||
| 72 | } |
||
| 73 | } |
||
| 74 | } |
||
| 75 |