AbstractClient::debugLog()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
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
declare(strict_types=1);
9
10
namespace Gitter\Adapters;
11
12
use Gitter\Client;
13
14
/**
15
 * Class AbstractClient
16
 * @package Gitter\Adapters
17
 */
18
abstract class AbstractClient implements AdapterInterface
19
{
20
    /**
21
     * @var array
22
     */
23
    protected $options = [];
24
25
    /**
26
     * @param Client $client
27
     * @return array
28
     */
29
    protected function buildHeaders(Client $client): array
30
    {
31
        return [
32
            'Accept'        => 'application/json',
33
            'Content-Type'  => 'application/json',
34
            'Authorization' => sprintf('Bearer %s', $client->token())
35
        ];
36
    }
37
38
    /**
39
     * @param array $options
40
     * @return AdapterInterface
41
     */
42
    public function setOptions(array $options = []): AdapterInterface
43
    {
44
        $this->options = array_merge_recursive($this->options, $options);
45
46
        return $this;
47
    }
48
49
    /**
50
     * @param Client $client
51
     * @param string $message
52
     */
53
    protected function debugLog(Client $client, string $message)
54
    {
55
        if ($client->logger !== null) {
56
            $client->logger->debug($message);
57
        }
58
    }
59
}
60