Passed
Push — master ( 00a57d...87b7fa )
by belamov
02:39
created

TimestampRangeCast   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRangeInstance() 0 3 1
A parseStringRange() 0 5 1
1
<?php
2
3
namespace Belamov\PostgresRange\Casts;
4
5
use Belamov\PostgresRange\Ranges\TimestampRange;
6
7
class TimestampRangeCast extends RangeCast
8
{
9
    /**
10
     * @param  array  $matches
11
     * @return TimestampRange
12
     */
13
    public function getRangeInstance(array $matches): TimestampRange
14
    {
15
        return new TimestampRange($matches[2], $matches[3], $matches[1], $matches[4]);
16
    }
17
18
    /**
19
     * @param  $value
20
     * @return array
21
     */
22
    protected function parseStringRange($value): array
23
    {
24
        $withoutQuotes = str_replace('"', '', $value);
25
26
        return parent::parseStringRange($withoutQuotes);
27
    }
28
}
29