Completed
Push — master ( b1bd72...501a41 )
by Sergey
12:53
created

CrudEndpoint   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 1
A update() 0 10 1
A delete() 0 10 1
1
<?php
2
3
namespace seregazhuk\Favro\Api\Endpoints;
4
5
class CrudEndpoint extends Endpoint
6
{
7
    /**
8
     * @param array $attributes
9
     * @return array
10
     */
11
    public function create(array $attributes)
12
    {
13
        return $this
14
            ->getHttp()
15
            ->post(
16
                $this->makeRequestUrl(),
17
                $attributes,
18
                $this->getHeaders()
19
            );
20
    }
21
22
    /**
23
     * @param string $itemId
24
     * @param array $attributes
25
     * @return mixed
26
     */
27
    public function update($itemId, array $attributes)
28
    {
29
        return $this
30
            ->getHttp()
31
            ->put(
32
                $this->makeRequestUrl($itemId),
33
                $attributes,
34
                $this->getHeaders()
35
            );
36
    }
37
38
    /**
39
     * @param string $itemId
40
     * @return mixed
41
     */
42
    public function delete($itemId)
43
    {
44
        return $this
45
            ->getHttp()
46
            ->delete(
47
                $this->makeRequestUrl($itemId),
48
                [],
49
                $this->getHeaders()
50
            );
51
    }
52
}