Deleteable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 3
eloc 7
c 3
b 1
f 0
dl 0
loc 46
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 6 1
A getDeletePath() 0 3 1
A setDeletePath() 0 3 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