| Conditions | 4 |
| Paths | 5 |
| Total Lines | 27 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 32 | protected function transform(array $params, array $attachmentPaths = []) |
||
| 33 | { |
||
| 34 | if (empty($attachmentPaths)) { |
||
| 35 | return ['form_params' => $params]; |
||
| 36 | } |
||
| 37 | |||
| 38 | $multipart = []; |
||
| 39 | |||
| 40 | foreach ($params as $key => $value) { |
||
| 41 | $multipart[] = [ |
||
| 42 | 'name' => $key, |
||
| 43 | 'contents' => $value |
||
| 44 | ]; |
||
| 45 | } |
||
| 46 | |||
| 47 | foreach ($attachmentPaths as $path) { |
||
| 48 | $pathParts = explode(DIRECTORY_SEPARATOR, $path); |
||
| 49 | $filename = end($pathParts); |
||
| 50 | |||
| 51 | $multipart[] = [ |
||
| 52 | 'name' => $filename, |
||
| 53 | 'contents' => fopen($path, 'r'), |
||
| 54 | 'filename' => $filename |
||
| 55 | ]; |
||
| 56 | } |
||
| 57 | |||
| 58 | return ['multipart' => $multipart]; |
||
| 59 | } |
||
| 61 |