DateRange::addToDiscreteBoundary()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 1
dl 0
loc 3
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace Belamov\PostgresRange\Ranges;
4
5
use Carbon\CarbonImmutable;
6
7
/**
8
 * Class DateRange.
9
 *
10
 * @method CarbonImmutable|null from()
11
 * @method CarbonImmutable|null to()
12
 */
13
class DateRange extends CanonicalRange
14
{
15
    use StringifiesBoundariesFromDateTimeInterface;
16
17
    /**
18
     * @param  string  $boundary
19
     * @return string
20
     */
21
    protected function addToDiscreteBoundary(string $boundary): string
22
    {
23
        return $this->transformBoundary($boundary)->addDay()->toDateString();
24
    }
25
26
    /**
27
     * @param  string  $boundary
28
     * @return CarbonImmutable
29
     */
30
    protected function transformBoundary(string $boundary): CarbonImmutable
31
    {
32
        return CarbonImmutable::parse($boundary);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected function getBoundaryFormat(): string
39
    {
40
        return 'Y-m-d';
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function forSql(): string
47
    {
48
        return "'$this'::daterange";
49
    }
50
}
51