ManagesSites   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
eloc 11
dl 0
loc 34
rs 10
c 3
b 0
f 2
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A siteByUrl() 0 5 1
A createSite() 0 5 1
A site() 0 5 1
A sites() 0 5 1
A deleteSite() 0 3 1
1
<?php
2
3
namespace OhDear\PhpSdk\Actions;
4
5
use OhDear\PhpSdk\Resources\Site;
6
7
trait ManagesSites
8
{
9
    public function sites(): array
10
    {
11
        return $this->transformCollection(
0 ignored issues
show
Bug introduced by
It seems like transformCollection() 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

11
        return $this->/** @scrutinizer ignore-call */ transformCollection(
Loading history...
12
            $this->get('sites')['data'],
0 ignored issues
show
Bug introduced by
It seems like get() 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

12
            $this->/** @scrutinizer ignore-call */ 
13
                   get('sites')['data'],
Loading history...
13
            Site::class,
14
        );
15
    }
16
17
    public function site(int $siteId): Site
18
    {
19
        $siteAttributes = $this->get("sites/{$siteId}");
20
21
        return new Site($siteAttributes, $this);
22
    }
23
24
    public function siteByUrl(string $siteUrl): Site
25
    {
26
        $siteAttributes = $this->get("sites/url/{$siteUrl}");
27
28
        return new Site($siteAttributes, $this);
29
    }
30
31
    public function createSite(array $data): Site
32
    {
33
        $siteAttributes = $this->post('sites', $data);
0 ignored issues
show
Bug introduced by
It seems like post() 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

33
        /** @scrutinizer ignore-call */ 
34
        $siteAttributes = $this->post('sites', $data);
Loading history...
34
35
        return new Site($siteAttributes, $this);
36
    }
37
38
    public function deleteSite(int $siteId)
39
    {
40
        $this->delete("sites/$siteId");
0 ignored issues
show
Bug introduced by
The method delete() does not exist on OhDear\PhpSdk\Actions\ManagesSites. Did you maybe mean deleteSite()? ( Ignorable by Annotation )

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

40
        $this->/** @scrutinizer ignore-call */ 
41
               delete("sites/$siteId");

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
    }
42
}
43