Completed
Push — master ( 9621c0...4bb787 )
by Tobias
01:47
created

Settings   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 4
dl 0
loc 40
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fetch() 0 13 3
A update() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Api;
6
7
use Billogram\Model\Setting\Setting;
8
9
/**
10
 * @author Ibrahim Hizeoui <[email protected]>
11
 */
12
class Settings extends HttpApi
13
{
14
    /**
15
     * @return mixed|\Psr\Http\Message\ResponseInterface
16
     *
17
     * @see https://billogram.com/api/documentation#settings_fetch
18
     */
19 1
    public function fetch()
20
    {
21 1
        $response = $this->httpGet('/settings');
22 1
        if (!$this->hydrator) {
23
            return $response;
24
        }
25
        // Use any valid status code here
26 1
        if ($response->getStatusCode() !== 200) {
27
            $this->handleErrors($response);
28
        }
29
30 1
        return $this->hydrator->hydrate($response, Setting::class);
31
    }
32
33
    /**
34
     * @return mixed|\Psr\Http\Message\ResponseInterface
35
     *
36
     * @see https://billogram.com/api/documentation#settings_fetch
37
     */
38 1
    public function update(Setting $setting)
39
    {
40 1
        $response = $this->httpPUT('/settings', $setting->toArray());
41 1
        if (!$this->hydrator) {
42
            return $response;
43
        }
44
        // Use any valid status code here
45 1
        if ($response->getStatusCode() !== 200) {
46
            $this->handleErrors($response);
47
        }
48
49 1
        return $this->hydrator->hydrate($response, Setting::class);
50
    }
51
}
52