Test Failed
Push — main ( e2347f...1d1810 )
by Dylan
14:48
created

Locations   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 5 1
A create() 0 5 1
A all() 0 2 1
A fetch() 0 5 1
1
<?php
2
3
namespace Lifeboat\Services;
4
5
use Lifeboat\Exceptions\ApiException;
6
use Lifeboat\Exceptions\OAuthException;
7
use Lifeboat\Models\Location;
8
use Lifeboat\Resource\ListResource;
9
10
/**
11
 * Class Locations
12
 * @package Lifeboat\Services
13
 */
14
class Locations extends ApiService {
15
16
    /**
17
     * @param int $id
18
     * @return Location|null
19
     * @throws ApiException
20
     * @throws OAuthException
21
     */
22
    public function fetch(int $id): ?Location
23
    {
24
        /** @var Location|null $fetch */
25
        $fetch = $this->_get('api/locations/location/' . $id);
26
        return $fetch;
27
    }
28
29
    /**
30
     * @param array $data
31
     * @return Location|null
32
     * @throws ApiException
33
     * @throws OAuthException
34
     */
35
    public function create(array $data): ?Location
36
    {
37
        /** @var Location|null $create */
38
        $create = $this->_post('api/locations/location', $data);
39
        return $create;
40
    }
41
42
    /**
43
     * @param int $id
44
     * @param array $data
45
     * @return Location|null
46
     * @throws ApiException
47
     * @throws OAuthException
48
     */
49
    public function update(int $id, array $data): ?Location
50
    {
51
        /** @var Location|null $post */
52
        $post = $this->_post('api/locations/location/' . $id, $data);
53
        return $post;
54
    }
55
56
    /**
57
     * @return ListResource
58
     */
59
    public function all(): ListResource {
60
        return new ListResource($this->getClient(), 'api/locations/all', [], 20);
61
    }
62
}
63