Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function load(string $filePath): Workout |
||
19 | { |
||
20 | Assertion::file($filePath); |
||
21 | Assertion::readable($filePath); |
||
22 | |||
23 | $extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); |
||
24 | switch ($extension) { |
||
25 | case 'gpx': |
||
26 | $loader = new GPX(); |
||
27 | break; |
||
28 | case 'tcx': |
||
29 | $loader = new TCX(); |
||
30 | break; |
||
31 | default: |
||
32 | throw new \RuntimeException(sprintf('No loader for file "%s"', $filePath)); |
||
33 | } |
||
34 | |||
35 | return $loader->load(file_get_contents($filePath)); |
||
36 | } |
||
37 | } |
||
38 |