Completed
Push — master ( 0708d4...99f0e4 )
by Rafał
02:36
created

GuzzleApiClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 59
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A sendRequest() 0 10 1
A addDefaultOptions() 0 4 1
A setOptions() 0 6 1
A getOptions() 0 4 1
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
namespace SWP\Bundle\BridgeBundle\Client;
15
16
use Superdesk\ContentApiSdk\Api\Request\RequestInterface;
17
use Superdesk\ContentApiSdk\Client\DefaultApiClient;
18
19
/**
20
 * Request service that implements all method regarding basic request/response
21
 * handling.
22
 */
23
class GuzzleApiClient extends DefaultApiClient
24
{
25
    /**
26
     * Options which come from Bundle configuration.
27
     *
28
     * @var array
29
     */
30
    protected $options = array();
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    protected function sendRequest(RequestInterface $request)
36
    {
37
        $request->setOptions(
38
            $this->addDefaultOptions(
39
                $request->getOptions()
40
            )
41
        );
42
43
        return parent::sendRequest($request);
44
    }
45
46
    /**
47
     * Merges property options with request options.
48
     *
49
     * @param array $options Request options
50
     *
51
     * @return array
52
     */
53
    public function addDefaultOptions($options)
54
    {
55
        return array_merge($options, $this->options);
56
    }
57
58
    /**
59
     * Sets default options.
60
     *
61
     * @param array $options
62
     *
63
     * @return self
64
     */
65
    public function setOptions(array $options)
66
    {
67
        $this->options = $options;
68
69
        return $this;
70
    }
71
72
    /**
73
     * Get options.
74
     *
75
     * @return array
76
     */
77
    public function getOptions()
78
    {
79
        return $this->options;
80
    }
81
}
82