Code Duplication    Length = 12-14 lines in 4 locations

src/Api/Server.php 4 locations

@@ 180-191 (lines=12) @@
177
     *
178
     * @return KernelEntity[]
179
     */
180
    public function getAvailableKernels($id)
181
    {
182
        $kernels = $this->adapter->get(\sprintf('%s/droplets/%d/kernels', $this->endpoint, $id));
183
184
        $kernels = \json_decode($kernels);
185
186
        $this->meta = $this->extractMeta($kernels);
187
188
        return \array_map(function ($kernel) {
189
            return new KernelEntity($kernel);
190
        }, $kernels->kernels);
191
    }
192
193
    /**
194
     * @param int $id
@@ 198-211 (lines=14) @@
195
     *
196
     * @return ImageEntity[]
197
     */
198
    public function getSnapshots($id)
199
    {
200
        $snapshots = $this->adapter->get(\sprintf('%s/droplets/%d/snapshots?per_page=%d', $this->endpoint, $id, 200));
201
202
        $snapshots = \json_decode($snapshots);
203
204
        $this->meta = $this->extractMeta($snapshots);
205
206
        return \array_map(function ($snapshot) {
207
            $snapshot = new ImageEntity($snapshot);
208
209
            return $snapshot;
210
        }, $snapshots->snapshots);
211
    }
212
213
    /**
214
     * @param int $id
@@ 218-229 (lines=12) @@
215
     *
216
     * @return ImageEntity[]
217
     */
218
    public function getBackups($id)
219
    {
220
        $backups = $this->adapter->get(\sprintf('%s/droplets/%d/backups?per_page=%d', $this->endpoint, $id, 200));
221
222
        $backups = \json_decode($backups);
223
224
        $this->meta = $this->extractMeta($backups);
225
226
        return \array_map(function ($backup) {
227
            return new ImageEntity($backup);
228
        }, $backups->backups);
229
    }
230
231
    /**
232
     * @param int $id
@@ 236-247 (lines=12) @@
233
     *
234
     * @return ActionEntity[]
235
     */
236
    public function getActions($id)
237
    {
238
        $actions = $this->adapter->get(\sprintf('%s/droplets/%d/actions?per_page=%d', $this->endpoint, $id, 200));
239
240
        $actions = \json_decode($actions);
241
242
        $this->meta = $this->extractMeta($actions);
243
244
        return \array_map(function ($action) {
245
            return new ActionEntity($action);
246
        }, $actions->actions);
247
    }
248
249
    /**
250
     * @param int $id