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