CanBeDeleted::delete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace seregazhuk\PinterestBot\Api\Traits;
4
5
/**
6
 * Trait CanBeDeleted
7
 *
8
 * @property string $deleteUrl
9
 */
10
trait CanBeDeleted
11
{
12
    use HandlesRequest, HasEntityIdName;
13
14
    protected function requiresLoginForCanBeDelete()
15
    {
16
        return [
17
            'delete',
18
        ];
19
    }
20
21
    /**
22
     * Delete entity by ID.
23
     *
24
     * @param int $entityId
25
     *
26
     * @return bool
27
     */
28
    public function delete($entityId)
29
    {
30
        return $this->post(
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->post($this...IdName() => $entityId)) also could return the type array which is incompatible with the documented return type boolean.
Loading history...
31
            $this->getDeleteUrl(),
32
            [$this->getEntityIdName() => $entityId]
33
        );
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    protected function getDeleteUrl()
40
    {
41
        return property_exists($this, 'deleteUrl') ? $this->deleteUrl : '';
42
    }
43
}
44