Conditions | 6 |
Paths | 6 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
27 | 44 | public function getValue(): string |
|
28 | { |
||
29 | 44 | $date = "DATEADD(hour, {$this->interval()}, {$this->wrap($this->value)})"; |
|
30 | |||
31 | 44 | switch ($this->unit) { |
|
32 | case Trend::BY_MONTHS: |
||
33 | 8 | return "FORMAT({$date}, 'yyyy-MM')"; |
|
34 | |||
35 | case Trend::BY_WEEKS: |
||
36 | 8 | return "concat(YEAR({$date}), '-', datepart(ISO_WEEK, {$date}))"; |
|
37 | |||
38 | case Trend::BY_DAYS: |
||
39 | 8 | return "FORMAT({$date}, 'yyyy-MM-dd')"; |
|
40 | |||
41 | case Trend::BY_HOURS: |
||
42 | 8 | return "FORMAT({$date}, 'yyyy-MM-dd HH:00')"; |
|
43 | |||
44 | case Trend::BY_MINUTES: |
||
45 | 8 | return "FORMAT({$date}, 'yyyy-MM-dd HH:mm:00')"; |
|
46 | |||
47 | default: |
||
48 | 4 | throw InvalidTrendUnitException::make($this->unit); |
|
49 | } |
||
50 | } |
||
51 | |||
68 |