Passed
Push — master ( f916ce...b72f24 )
by belamov
11:20 queued 10s
created

TimeRange::forSql()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Belamov\PostgresRange\Ranges;
4
5
use Carbon\CarbonImmutable;
6
7
/**
8
 * Class TimeRange.
9
 *
10
 * @method string|null from()
11
 * @method string|null to()
12
 */
13
class TimeRange extends Range
14
{
15
    use StringifiesBoundariesFromDateTimeInterface;
16
17
    public function forSql(): string
18
    {
19
        $timerangeTypeName = config('postgres-range.timerange_typename');
20
        return "'$this'::$timerangeTypeName";
21
    }
22
23
    /**
24
     * @param  string  $boundary
25
     * @return string
26
     */
27
    protected function transformBoundary(string $boundary): string
28
    {
29
        return CarbonImmutable::parse($boundary)->toTimeString();
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    protected function getBoundaryFormat(): string
36
    {
37
        return 'H:i:s';
38
    }
39
}
40