| Conditions | 6 |
| Paths | 6 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 88 | public function getValue(): string |
|
| 28 | { |
||
| 29 | 88 | $interval = $this->interval(); |
|
| 30 | |||
| 31 | 88 | switch ($this->unit) { |
|
| 32 | case Trend::BY_MONTHS: |
||
| 33 | 16 | return "date_format({$this->wrap($this->value)}{$interval}, '%Y-%m')"; |
|
| 34 | |||
| 35 | case Trend::BY_WEEKS: |
||
| 36 | 16 | return "date_format({$this->wrap($this->value)}{$interval}, '%x-%v')"; |
|
| 37 | |||
| 38 | case Trend::BY_DAYS: |
||
| 39 | 16 | return "date_format({$this->wrap($this->value)}{$interval}, '%Y-%m-%d')"; |
|
| 40 | |||
| 41 | case Trend::BY_HOURS: |
||
| 42 | 16 | return "date_format({$this->wrap($this->value)}{$interval}, '%Y-%m-%d %H:00')"; |
|
| 43 | |||
| 44 | case Trend::BY_MINUTES: |
||
| 45 | 16 | return "date_format({$this->wrap($this->value)}{$interval}, '%Y-%m-%d %H:%i:00')"; |
|
| 46 | |||
| 47 | default: |
||
| 48 | 8 | throw InvalidTrendUnitException::make($this->unit); |
|
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 77 |