| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 28 | public function reverseTransform($value) |
||
| 29 | { |
||
| 30 | if (null === $value['base64']) { |
||
| 31 | return null; |
||
| 32 | } |
||
| 33 | |||
| 34 | $base64 = str_replace('data:image/png;base64,', '', $value['base64']); |
||
| 35 | |||
| 36 | $filePath = tempnam(sys_get_temp_dir(), 'UploadedFile'); |
||
| 37 | $file = fopen($filePath, 'w'); |
||
| 38 | stream_filter_append($file, 'convert.base64-decode'); |
||
| 39 | fwrite($file, $base64); |
||
| 40 | $meta_data = stream_get_meta_data($file); |
||
| 41 | $path = $meta_data['uri']; |
||
| 42 | fclose($file); |
||
| 43 | |||
| 44 | // Force "test" parameters to true to bypass http file validation (as the file isn't a "real" uploaded file) |
||
| 45 | return new UploadedFile($path, uniqid(), null, null, null, true); |
||
| 46 | } |
||
| 47 | } |
||
| 48 |