Code Duplication    Length = 13-17 lines in 3 locations

src/Command/DeleteCommand.php 1 location

@@ 75-87 (lines=13) @@
72
        return 0;
73
    }
74
75
    private function deleteIndex(string $indexName): void
76
    {
77
        try {
78
            $path = sprintf('%s', $indexName);
79
            $this->client->request($path, Request::DELETE);
80
        } catch (ExceptionInterface $deleteOldIndexException) {
81
            throw new \RuntimeException(sprintf('Failed to delete index %s with message: %s', $indexName, $deleteOldIndexException->getMessage()), 0, $deleteOldIndexException);
82
        }
83
    }
84
}
85

src/Index/AliasProcessor.php 2 locations

@@ 139-151 (lines=13) @@
136
     *
137
     * @param string $indexName Index name to delete
138
     */
139
    private function deleteIndex(Client $client, $indexName)
140
    {
141
        try {
142
            $path = sprintf('%s', $indexName);
143
            $client->request($path, Request::DELETE);
144
        } catch (ExceptionInterface $deleteOldIndexException) {
145
            throw new \RuntimeException(sprintf('Failed to delete index %s with message: %s', $indexName, $deleteOldIndexException->getMessage()), 0, $deleteOldIndexException);
146
        }
147
    }
148
149
    /**
150
     * Close an index.
151
     *
152
     * @param string $indexName
153
     */
154
    private function closeIndex(Client $client, $indexName)
@@ 154-170 (lines=17) @@
151
     *
152
     * @param string $indexName
153
     */
154
    private function closeIndex(Client $client, $indexName)
155
    {
156
        try {
157
            $path = sprintf('%s/_close', $indexName);
158
            $client->request($path, Request::POST);
159
        } catch (ExceptionInterface $e) {
160
            throw new \RuntimeException(sprintf('Failed to close index %s with message: %s', $indexName, $e->getMessage()), 0, $e);
161
        }
162
    }
163
164
    /**
165
     * Returns the name of a single index that an alias points to or throws
166
     * an exception if there is more than one.
167
     *
168
     * @param string $aliasName Alias name
169
     *
170
     * @return string|null
171
     *
172
     * @throws AliasIsIndexException
173
     */