Image   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A list() 0 6 1
A create() 0 6 1
1
<?php
2
/*
3
 *   This file is part of the Vultr PHP library.
4
 *
5
 *   (c) Albert Leitato <[email protected]>
6
 *
7
 *   For the full copyright and license information, please view the LICENSE
8
 *   file that was distributed with this source code.
9
 */
10
namespace Vultr\Api;
11
12
use Vultr\Entity\Image as ImageEntity;
13
use Vultr\Exception\HttpException;
14
15
/**
16
 * @author Albert Leitato <[email protected]>
17
 */
18
class Image extends AbstractApi
19
{
20
    /**
21
     * List all ISOs currently available on this account.
22
     *
23
     * @return ImageEntity[]
24
     */
25
    public function list()
26
    {
27
        $images = $this->adapter->get(\sprintf('%s/iso/list', $this->endpoint));
28
29
        return $this->handleResponse($images, ImageEntity::class, true);
30
    }
31
32
    /**
33
     * Create a new ISO image on the current account.
34
     *
35
     * The ISO image will be downloaded from a given URL.
36
     * Download status can be checked with the v1/iso/list call.
37
     *
38
     * @param string $url
39
     *
40
     * @throws HttpException
41
     *
42
     * @return mixed Api response
43
     */
44
    public function create($url)
45
    {
46
        $image = $this->adapter->post(\sprintf('%s/iso/create_from_url', $this->endpoint), ['url' => $url]);
47
48
        return \json_decode($image);
49
    }
50
}
51