| Conditions | 4 |
| Paths | 6 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function saveLabels(string $extension, string $prefix = 'label-', string $dir = null) : array |
||
| 16 | { |
||
| 17 | if (!$dir) { |
||
|
|
|||
| 18 | $dir = sys_get_temp_dir(); |
||
| 19 | } |
||
| 20 | $dir = rtrim($dir, '/'); |
||
| 21 | |||
| 22 | $files = []; |
||
| 23 | |||
| 24 | foreach ($this->data['Labels'] as $label) { |
||
| 25 | $decoded = base64_decode($label['Content']); |
||
| 26 | |||
| 27 | if ($decoded === false) { |
||
| 28 | throw new InvalidBase64Exception('An error occurred during the base64_decode'); |
||
| 29 | } |
||
| 30 | |||
| 31 | $file = $this->getFile($extension, $prefix, $dir); |
||
| 32 | $file->fwrite($decoded); |
||
| 33 | |||
| 34 | $files[] = $file; |
||
| 35 | } |
||
| 36 | |||
| 37 | return $files; |
||
| 38 | } |
||
| 39 | |||
| 49 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: