| Conditions | 4 |
| Paths | 6 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function save(array $data, string $id = null): string |
||
| 17 | { |
||
| 18 | foreach ($data['profile'] as $index => &$profile) { |
||
| 19 | // skip empty profilings |
||
| 20 | if (!$profile) { |
||
| 21 | unset($data['profile'][$index]); |
||
| 22 | continue; |
||
| 23 | } |
||
| 24 | |||
| 25 | // normalize, fill all missing keys |
||
| 26 | $profile += [ |
||
| 27 | 'ct' => 0, |
||
| 28 | 'wt' => 0, |
||
| 29 | 'cpu' => 0, |
||
| 30 | 'mu' => 0, |
||
| 31 | 'pmu' => 0, |
||
| 32 | ]; |
||
| 33 | } |
||
| 34 | unset($profile); |
||
| 35 | |||
| 36 | if (!$data['profile']) { |
||
| 37 | throw new RuntimeException("Skipping to save empty profiling"); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $this->saver->save($data, $id); |
||
| 41 | } |
||
| 42 | } |
||
| 43 |