Completed
Push — master ( a2b906...d5b295 )
by Peter
03:27
created

Server   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 58
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A read() 0 4 1
A create() 0 4 1
A delete() 0 4 1
A images() 0 4 1
1
<?php
2
3
namespace PeterColes\Cluster\Servers;
4
5
use PeterColes\Cluster\Contracts\Factory;
6
use PeterColes\Cluster\Contracts\ServerAdapterInterface;
7
use PeterColes\Cluster\Contracts\HttpClientInterface;
8
9
class Server extends Factory
10
{
11
    /**
12
     * Constructor - receive server adapter, adapter api authentication and http client details.
13
     * Initialise the http client and make it available for use by the server adapter.
14
     *
15
     * @param ServerAdapterInterface $adapter
16
     * @param HttpClientInterface $client
17
     */
18
    public function __construct(ServerAdapterInterface $adapter, HttpClientInterface $client = null)
19
    {
20
        $this->init($adapter, $client);
21
    }
22
23
    /**
24
     * List details for an indexed server, or all servers if id is null.
25
     *
26
     * @param integer $id
27
     * @return GuzzleResponse | array of GuzzleResponse objects
28
     */
29
    public function read($id = null)
30
    {
31
        return $this->adapter->read($id);
32
    }
33
34
    /**
35
     * Create a new server based on parameters received.
36
     *
37
     * @param array $params
38
     * @return array
39
     */
40
    public function create($params)
41
    {
42
        return $this->adapter->create($params);
43
    }
44
45
    /**
46
     * Delete the server corresponding to the given id.
47
     *
48
     * @param integer $id
49
     * @return integer
50
     */
51
    public function delete($id)
52
    {
53
        return $this->adapter->delete($id);
54
    }
55
56
    /**
57
     * List available server images.
58
     *
59
     * @param array $params     list of qualifiers to filter the response
60
     * @return array
61
     */
62
    public function images($params = [])
63
    {
64
        return $this->adapter->images($params);
65
    }
66
}
67