Passed
Pull Request — master (#32)
by
unknown
02:09
created

TimestampRangeCast   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRangeInstance() 0 3 1
A parseStringRange() 0 4 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
        return parent::parseStringRange($withoutQuotes);
26
    }
27
}
28