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

Factory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 16 2
1
<?php
2
3
namespace PeterColes\Cluster\Contracts;
4
5
abstract class Factory
6
{
7
    /**
8
     * The adapter being constructed by the factory
9
     */
10
    protected $adapter;
11
12
    /**
13
     * Initialise the adapter, including injecting an http client
14
     *
15
     * @param object $adapter
16
     * @param object $client
17
     * @return void
18
     */
19
    public function init($adapter, $client = null)
20
    {
21
        // set the server adapter
22
        $this->adapter = $adapter;
23
24
        // for ease of use we can fallback to a default http client
25
        if (!$client) {
26
            $client = new \PeterColes\Cluster\HttpClients\GuzzleHttp;
27
        }
28
29
        // initialise the http client with the authentication header options
30
        $client->initClient($this->adapter->getHeaders());
31
32
        // make the initialised http client available to the adapter
33
        $this->adapter->setClient($client);
34
    }
35
}
36