TimeRange   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 6
c 1
b 1
f 0
dl 0
loc 26
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A transformBoundary() 0 3 1
A getBoundaryFormat() 0 3 1
A forSql() 0 5 1
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