Code Duplication    Length = 13-17 lines in 2 locations

Index/AliasProcessor.php 2 locations

@@ 160-172 (lines=13) @@
157
     * @param Client $client
158
     * @param string $indexName Index name to delete
159
     */
160
    private function deleteIndex(Client $client, $indexName)
161
    {
162
        try {
163
            $path = sprintf('%s', $indexName);
164
            $client->request($path, Request::DELETE);
165
        } catch (ExceptionInterface $deleteOldIndexException) {
166
            throw new \RuntimeException(sprintf(
167
                'Failed to delete index %s with message: %s',
168
                $indexName,
169
                $deleteOldIndexException->getMessage()
170
            ), 0, $deleteOldIndexException);
171
        }
172
    }
173
174
    /**
175
     * Close an index.
@@ 180-196 (lines=17) @@
177
     * @param Client $client
178
     * @param string $indexName
179
     */
180
    private function closeIndex(Client $client, $indexName)
181
    {
182
        try {
183
            $path = sprintf('%s/_close', $indexName);
184
            $client->request($path, Request::POST);
185
        } catch (ExceptionInterface $e) {
186
            throw new \RuntimeException(
187
                sprintf(
188
                    'Failed to close index %s with message: %s',
189
                    $indexName,
190
                    $e->getMessage()
191
                ),
192
                0,
193
                $e
194
            );
195
        }
196
    }
197
198
    /**
199
     * Returns the name of a single index that an alias points to or throws