| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 73 | protected function parseFile() |
||
| 74 | { |
||
| 75 | $attributes = []; |
||
| 76 | $path = $this->path; |
||
| 77 | if (file_exists($path)) { |
||
| 78 | $ext = pathinfo($path, PATHINFO_EXTENSION); |
||
| 79 | $mimeType = mime_content_type($path); |
||
| 80 | $attributes['name'] = pathinfo($path, PATHINFO_FILENAME) . '.' . $ext; |
||
| 81 | $attributes['type'] = $mimeType; |
||
| 82 | $content = file_get_contents($path); |
||
| 83 | $base64 = 'data:' . $mimeType . ';base64,' . base64_encode($content); |
||
| 84 | $attributes['data'] = $base64; |
||
| 85 | } else { |
||
| 86 | throw new \Exception(sprintf('File %s not found', $path)); |
||
| 87 | } |
||
| 88 | |||
| 89 | return $attributes; |
||
| 90 | } |
||
| 91 | } |