Completed
Push — master ( 5bf22f...cf1632 )
by Kirill
06:39
created

AbstractClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildHeaders() 0 8 1
A setOptions() 0 6 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of GitterApi package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
namespace Gitter\Adapters;
9
10
use Gitter\Client;
11
12
/**
13
 * Class AbstractClient
14
 * @package Gitter\Adapters
15
 */
16
abstract class AbstractClient implements AdapterInterface
17
{
18
    /**
19
     * @var array
20
     */
21
    protected $options = [];
22
23
    /**
24
     * @param Client $client
25
     * @return array
26
     */
27
    protected function buildHeaders(Client $client): array
28
    {
29
        return [
30
            'Accept'        => 'application/json',
31
            'Content-Type'  => 'application/json',
32
            'Authorization' => sprintf('Bearer %s', $client->token())
33
        ];
34
    }
35
36
    /**
37
     * @param array $options
38
     * @return AdapterInterface
39
     */
40
    public function setOptions(array $options = []): AdapterInterface
41
    {
42
        $this->options = $options;
43
44
        return $this;
45
    }
46
}
47