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 | $interval = $this->interval(); |
|
30 | |||
31 | 44 | switch ($this->unit) { |
|
32 | case Trend::BY_MONTHS: |
||
33 | 8 | return "to_char({$this->wrap($this->value)}{$interval}, 'YYYY-MM')"; |
|
34 | |||
35 | case Trend::BY_WEEKS: |
||
36 | 8 | return "to_char({$this->wrap($this->value)}{$interval}, 'IYYY-IW')"; |
|
37 | |||
38 | case Trend::BY_DAYS: |
||
39 | 8 | return "to_char({$this->wrap($this->value)}{$interval}, 'YYYY-MM-DD')"; |
|
40 | |||
41 | case Trend::BY_HOURS: |
||
42 | 8 | return "to_char({$this->wrap($this->value)}{$interval}, 'YYYY-MM-DD HH24:00')"; |
|
43 | |||
44 | case Trend::BY_MINUTES: |
||
45 | 8 | return "to_char({$this->wrap($this->value)}{$interval}, 'YYYY-MM-DD HH24:mi:00')"; |
|
46 | |||
47 | default: |
||
48 | 4 | throw InvalidTrendUnitException::make($this->unit); |
|
49 | } |
||
50 | } |
||
51 | |||
77 |