| Total Complexity | 4 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | trait Duration |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Retrieve the total duration in minutes with decimals. |
||
| 18 | * |
||
| 19 | * @return float |
||
| 20 | */ |
||
| 21 | abstract public function getTotalDurationAttribute(); |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Retrieve total duration converted to hours. |
||
| 25 | * |
||
| 26 | * @return string |
||
| 27 | */ |
||
| 28 | public function getTotalHoursAttribute() |
||
| 29 | { |
||
| 30 | return (new TimeConverter())->setMinutes($this->total_duration)->getHours(); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Retrieve total duration converted to minutes without decimals. |
||
| 35 | * |
||
| 36 | * @return false|float |
||
| 37 | */ |
||
| 38 | public function getTotalMinutesAttribute() |
||
| 39 | { |
||
| 40 | return floor($this->total_duration); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Retrieve total duration converted to seconds. |
||
| 45 | * |
||
| 46 | * @return float|int |
||
| 47 | */ |
||
| 48 | public function getTotalSecondsAttribute() |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Retrieve total seconds converted to 'hours:minutes:seconds' datetime. |
||
| 55 | * |
||
| 56 | * @return string |
||
| 57 | */ |
||
| 58 | public function getTotalTimeAttribute() |
||
| 61 | } |
||
| 62 | } |
||
| 63 |