GuzzleApiClient::getOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Bridge for the Content API.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\BridgeBundle\Client;
16
17
use Superdesk\ContentApiSdk\Api\Request\RequestInterface;
18
use Superdesk\ContentApiSdk\Client\DefaultApiClient;
19
20
/**
21
 * Request service that implements all method regarding basic request/response
22
 * handling.
23
 */
24
class GuzzleApiClient extends DefaultApiClient
25
{
26
    /**
27
     * Options which come from Bundle configuration.
28
     *
29
     * @var array
30
     */
31
    protected $options = [];
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function sendRequest(RequestInterface $request)
37
    {
38
        $request->setOptions(
39
            $this->addDefaultOptions(
40
                $request->getOptions()
41
            )
42
        );
43
44
        return parent::sendRequest($request);
45
    }
46
47
    /**
48
     * Merges property options with request options.
49
     *
50
     * @param array $options Request options
51
     *
52
     * @return array
53
     */
54
    public function addDefaultOptions($options)
55
    {
56
        return array_merge($options, $this->options);
57
    }
58
59
    /**
60
     * Sets default options.
61
     *
62
     * @param array $options
63
     *
64
     * @return self
65
     */
66
    public function setOptions(array $options)
67
    {
68
        $this->options = $options;
69
70
        return $this;
71
    }
72
73
    /**
74
     * Get options.
75
     *
76
     * @return array
77
     */
78
    public function getOptions()
79
    {
80
        return $this->options;
81
    }
82
}
83