Test Failed
Push — master ( 7c4720...fd955c )
by Lyal
04:00 queued 14s
created

Deleteable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 26
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 5 1
A getDeletePath() 0 3 1
A setDeletePath() 0 3 1
1
<?php
2
namespace Lyal\Checkr\Traits;
3
4
trait Deleteable
5
{
6
    private $deletePath;
7
8
    /**
9
     * Deletes the given resource, returns a client instance
10
     *
11
     * @param null $id
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $id is correct as it would always require null to be passed?
Loading history...
12
     * @return \Lyal\Checkr\Client $client
13
     */
14
15
    public function delete($id = null) : \Lyal\Checkr\Client
16
    {
17
        $this->setAttribute('id', $id ?? $this->getAttribute('id'));
0 ignored issues
show
Bug introduced by
It seems like getAttribute() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        $this->setAttribute('id', $id ?? $this->/** @scrutinizer ignore-call */ getAttribute('id'));
Loading history...
Bug introduced by
It seems like setAttribute() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        $this->/** @scrutinizer ignore-call */ 
18
               setAttribute('id', $id ?? $this->getAttribute('id'));
Loading history...
18
        $this->getClient()->request('delete', $this->getDeletePath());
0 ignored issues
show
Bug introduced by
It seems like getClient() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        $this->/** @scrutinizer ignore-call */ 
19
               getClient()->request('delete', $this->getDeletePath());
Loading history...
19
        return $this->getClient();
20
    }
21
22
    public function getDeletePath()
23
    {
24
        return $this->deletePath ?? $this->getResourceName() . '/' . $this->getAttribute('id');
0 ignored issues
show
Bug introduced by
It seems like getResourceName() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return $this->deletePath ?? $this->/** @scrutinizer ignore-call */ getResourceName() . '/' . $this->getAttribute('id');
Loading history...
25
    }
26
27
    public function setDeletePath($path) : void
28
    {
29
        $this->deletePath = $path;
30
    }
31
32
}