Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
CalculatesTime | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
secondsFromTime | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Engelsystem\Helpers\Schedule; |
6 | |
7 | trait CalculatesTime |
8 | { |
9 | protected function secondsFromTime(string $time): int |
10 | { |
11 | $seconds = 0; |
12 | $duration = explode(':', $time); |
13 | |
14 | foreach (array_slice($duration, 0, 2) as $key => $times) { |
15 | $seconds += [60 * 60, 60][$key] * (int) $times; |
16 | } |
17 | |
18 | return $seconds; |
19 | } |
20 | } |