Adapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 60
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setClient() 0 4 1
A setHeaders() 0 4 1
A getHeaders() 0 4 1
1
<?php
2
3
namespace PeterColes\Cluster\Contracts;
4
5
abstract class Adapter
6
{
7
    /**
8
     * Params used to initialise this instance, e.g. authentication parameters for the Digital Ocean API.
9
     */
10
    protected $params;
11
12
    /**
13
     * The http client that will manage API requests and handle responses.
14
     */
15
    protected $client;
16
17
    /**
18
     * The headers to proceed the API request in order to authenticate it.
19
     */
20
    protected $headers;
21
22
    /**
23
     * Constructor. Receive and record parameters. Use them to set request headers.
24
     *
25
     * @param array $params
26
     */
27
    public function __construct($params)
28
    {
29
        $this->params = $params;
30
31
        $this->setHeaders();
32
    }
33
34
    /**
35
     * Set the client class var.
36
     *
37
     * @param GuzzleHttp\Client $client
38
     * @return void
39
     */
40
    public function setClient($client)
41
    {
42
        $this->client = $client;
43
    }
44
45
    /**
46
     * Construct http client request headers.
47
     *
48
     * @return void
49
     */
50
    protected function setHeaders()
51
    {
52
        $this->headers['headers']['Content-Type'] = 'application/json';
53
    }
54
55
    /**
56
     * Get headers for https client.
57
     *
58
     * @return array
59
     */
60
    public function getHeaders()
61
    {
62
        return $this->headers;
63
    }
64
}
65