TimeRange::getBoundaryFormat()   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 0
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 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
21
        return "'$this'::$timerangeTypeName";
22
    }
23
24
    /**
25
     * @param  string  $boundary
26
     * @return string
27
     */
28
    protected function transformBoundary(string $boundary): string
29
    {
30
        return CarbonImmutable::parse($boundary)->toTimeString();
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function getBoundaryFormat(): string
37
    {
38
        return 'H:i:s';
39
    }
40
}
41