Code Duplication    Length = 33-33 lines in 2 locations

src/Lodash/ElasticSearch/ElasticSearchManager.php 2 locations

@@ 126-158 (lines=33) @@
123
        $this->deleteIndexes($indexes);
124
    }
125
126
    public function addDocumentsToIndex(string $index_name, string $type_name, array $items)
127
    {
128
        if (! $this->isEnabled()) {
129
            return;
130
        }
131
132
        $params = [
133
            'body' => [],
134
        ];
135
136
        if (! empty($this->timeout)) {
137
            $params['client'] = [
138
                'timeout' => $this->timeout,
139
            ];
140
        }
141
142
        foreach ($items as $id => $item) {
143
            $params['body'][] = [
144
                'create' => [
145
                    '_index' => $index_name,
146
                    '_type'  => $type_name,
147
                    '_id'    => $id,
148
                ],
149
            ];
150
151
            $params['body'][] = $item;
152
        }
153
154
        $responses = $this->client->bulk($params);
155
        if ($responses['errors'] === true) {
156
            throw new RuntimeException('Error occurred during bulk insert');
157
        }
158
    }
159
160
    public function updateDocumentsInIndex(string $index_name, string $type_name, array $items)
161
    {
@@ 160-192 (lines=33) @@
157
        }
158
    }
159
160
    public function updateDocumentsInIndex(string $index_name, string $type_name, array $items)
161
    {
162
        if (! $this->isEnabled()) {
163
            return;
164
        }
165
166
        $params = [
167
            'body' => [],
168
        ];
169
170
        if (! empty($this->timeout)) {
171
            $params['client'] = [
172
                'timeout' => $this->timeout,
173
            ];
174
        }
175
176
        foreach ($items as $id => $item) {
177
            $params['body'][] = [
178
                'update' => [
179
                    '_index' => $index_name,
180
                    '_type'  => $type_name,
181
                    '_id'    => $id,
182
                ],
183
            ];
184
185
            $params['body'][] = ['doc' => $item];
186
        }
187
188
        $responses = $this->client->bulk($params);
189
        if ($responses['errors'] === true) {
190
            throw new RuntimeException('Error occurred during bulk insert');
191
        }
192
    }
193
194
    public function refreshIndex(string $index_name)
195
    {