| 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 | 88 | public function getValue() |
|
| 25 | { |
||
| 26 | 88 | $interval = $this->interval(); |
|
| 27 | |||
| 28 | 88 | switch ($this->unit) { |
|
| 29 | 66 | case Trend::BY_MONTHS: |
|
| 30 | 16 | return "date_format({$this->wrap($this->value)}{$interval}, '%Y-%m')"; |
|
| 31 | |||
| 32 | 54 | case Trend::BY_WEEKS: |
|
| 33 | 16 | return "date_format({$this->wrap($this->value)}{$interval}, '%x-%v')"; |
|
| 34 | |||
| 35 | 42 | case Trend::BY_DAYS: |
|
| 36 | 16 | return "date_format({$this->wrap($this->value)}{$interval}, '%Y-%m-%d')"; |
|
| 37 | |||
| 38 | 30 | case Trend::BY_HOURS: |
|
| 39 | 16 | return "date_format({$this->wrap($this->value)}{$interval}, '%Y-%m-%d %H:00')"; |
|
| 40 | |||
| 41 | 18 | case Trend::BY_MINUTES: |
|
| 42 | 16 | return "date_format({$this->wrap($this->value)}{$interval}, '%Y-%m-%d %H:%i:00')"; |
|
| 43 | |||
| 44 | default: |
||
| 45 | 8 | throw InvalidTrendUnitException::make($this->unit); |
|
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 71 |