Deleteable::setDeletePath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 1
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Lyal\Checkr\Traits;
4
5
trait Deleteable
6
{
7
    private $deletePath;
8
9
    /**
10
     * Abstract functions to imppose requirements for the exhibiting class.
11
     */
12
    abstract public function getResourceName($object = null);
13
14
    abstract public function getAttributes($sanitized = true);
15
16
    abstract public function getAttribute($key);
17
18
    abstract public function setAttribute($key, $value);
19
20
    abstract public function processPath($path = null, array $values = null);
21
22
    abstract public function postRequest($path, array $options = []);
23
24
    abstract public function getClient();
25
26
    abstract public function setValues($values);
27
28
    /**
29
     * Deletes the given resource, returns a client instance.
30
     *
31
     * @param string|null $id
32
     *
33
     * @return \Lyal\Checkr\Client $client
34
     */
35
    public function delete($id = null)
36
    {
37
        $this->setAttribute('id', $id ?? $this->getAttribute('id'));
38
        $this->getClient()->request('delete', $this->getDeletePath());
39
40
        return $this->getClient();
41
    }
42
43
    public function getDeletePath()
44
    {
45
        return $this->deletePath ?? $this->getResourceName().'/'.$this->getAttribute('id');
46
    }
47
48
    public function setDeletePath($path)
49
    {
50
        $this->deletePath = $path;
51
    }
52
}
53