Completed
Push — master ( d233d7...a08bf1 )
by Kirill
02:31
created

AbstractClient::debugLog()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
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
    /**
48
     * @param Client $client
49
     * @param string $message
50
     */
51
    protected function debugLog(Client $client, string $message)
52
    {
53
        if ($client->logger !== null) {
54
            $client->logger->debug($message);
55
        }
56
    }
57
}
58