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

CrudEndpoint::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 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
}