Code Duplication    Length = 16-16 lines in 2 locations

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
    }

src/Mailgun/Api/Message.php 1 location

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