Code Duplication    Length = 16-16 lines in 2 locations

src/Mailgun/Api/Message.php 1 location

@@ 47-62 (lines=16) @@
44
            unset($params[$fieldName]);
45
        }
46
47
        foreach ($params as $key => $value) {
48
            if (is_array($value)) {
49
                $index = 0;
50
                foreach ($value as $subValue) {
51
                    $postDataMultipart[] = [
52
                        'name' => sprintf('%s[%d]', $key, $index++),
53
                        'content' => $subValue,
54
                    ];
55
                }
56
            } else {
57
                $postDataMultipart[] = [
58
                    'name' => $key,
59
                    'content' => $value,
60
                ];
61
            }
62
        }
63
64
        $response = $this->httpPostRaw(sprintf('/v3/%s/messages', $domain), $postDataMultipart);
65

src/Mailgun/Connection/RestClient.php 1 location

@@ 143-158 (lines=16) @@
140
        }
141
142
        $postDataMultipart = [];
143
        foreach ($postData as $key => $value) {
144
            if (is_array($value)) {
145
                $index = 0;
146
                foreach ($value as $subValue) {
147
                    $postDataMultipart[] = [
148
                        'name' => sprintf('%s[%d]', $key, $index++),
149
                        'contents' => $subValue,
150
                    ];
151
                }
152
            } else {
153
                $postDataMultipart[] = [
154
                    'name' => $key,
155
                    'contents' => $value,
156
                ];
157
            }
158
        }
159
160
        return $this->send('POST', $endpointUrl, [], array_merge($postDataMultipart, $postFiles));
161
    }