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