CrudEndpoint::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
namespace seregazhuk\Favro\Api\Endpoints;
4
5
abstract 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
            ->http
15
            ->post(
16
                $this->makeRequestUrl(),
17
                $attributes,
18
                $this->headers()
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
            ->http
31
            ->put(
32
                $this->makeRequestUrl($itemId),
33
                $attributes,
34
                $this->headers()
35
            );
36
    }
37
38
    /**
39
     * @param string $itemId
40
     * @param bool $everywhere
41
     * @return mixed
42
     */
43
    public function delete($itemId, $everywhere = false)
44
    {
45
        $params = $everywhere ? ['everywhere' => $everywhere] : [];
46
47
        return $this
48
            ->http
49
            ->delete(
50
                $this->makeRequestUrl($itemId),
51
                $params,
52
                $this->headers()
53
            );
54
    }
55
}
56