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