Conditions | 2 |
Paths | 2 |
Total Lines | 18 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
34 | protected function parseFile() |
||
35 | { |
||
36 | $attributes = []; |
||
37 | $path = $this->path; |
||
38 | if (file_exists($path)) { |
||
39 | $ext = pathinfo($path, PATHINFO_EXTENSION); |
||
40 | $mimeType = mime_content_type($path); |
||
41 | $attributes['name'] = pathinfo($path, PATHINFO_FILENAME) . '.' . $ext; |
||
42 | $attributes['type'] = $mimeType; |
||
43 | $content = file_get_contents($path); |
||
44 | $base64 = 'data:' . $mimeType . ';base64,' . base64_encode($content); |
||
45 | $attributes['data'] = $base64; |
||
46 | } else { |
||
47 | throw new \Exception('Missing "file" or "data" attribute.'); |
||
48 | } |
||
49 | |||
50 | return $attributes; |
||
51 | } |
||
52 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.