Completed
Pull Request — master (#120)
by Sergey
02:56
created

CanBeDeleted::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace seregazhuk\PinterestBot\Api\Traits;
4
5
/**
6
 * Class CanBeDeleted
7
 * @package seregazhuk\PinterestBot\Api\Traits
8
 *
9
 * @property string $deleteUrl
10
 */
11
trait CanBeDeleted
12
{
13
    use HandlesRequestAndResponse, HasEntityIdName;
14
15
    /**
16
     * Delete entity by ID.
17
     *
18
     * @param int $entityId
19
     *
20
     * @return bool
21
     */
22
    public function delete($entityId)
23
    {
24
        return $this->execPostRequest([$this->getEntityIdName() => $entityId], $this->getDeleteUrl());
25
    }
26
27
    protected function getDeleteUrl()
28
    {
29
        return property_exists($this, 'deleteUrl') ? $this->deleteUrl : '';
30
    }
31
}