SubsitesService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubsitesService() 0 7 3
A getSubsite() 0 3 1
1
<?php
2
3
namespace Osnova\Services\Subsites\Traits;
4
5
use Osnova\Api\ApiProvider;
6
use Osnova\Services\Subsites\Subsite;
7
use Osnova\Services\Subsites\Subsites;
8
9
trait SubsitesService
10
{
11
    /** @var Subsites|null */
12
    private $subsites;
13
14
    /**
15
     * Get the resource API Provider instance.
16
     *
17
     * @return ApiProvider
18
     */
19
    abstract public function getApiProvider();
20
21
    /**
22
     * Get the subsites service instance.
23
     *
24
     * @param bool $reload = false Reload instance flag.
25
     *
26
     * @return Subsites()
27
     */
28
    public function getSubsitesService(bool $reload = false)
29
    {
30
        if (is_null($this->subsites) || $reload) {
31
            return $this->subsites = new Subsites($this->getApiProvider());
32
        }
33
34
        return $this->subsites;
35
    }
36
37
    /**
38
     * Get subsite.
39
     * This is a proxy method for Subsites::getSubsite().
40
     *
41
     * @param int $id
42
     *
43
     * @see Subsites::getSubsite()
44
     *
45
     * @return Subsite|null
46
     */
47
    public function getSubsite($id)
48
    {
49
        return $this->getSubsitesService()->getSubsite($id, $this);
0 ignored issues
show
Bug introduced by
$this of type Osnova\Services\Subsites\Traits\SubsitesService is incompatible with the type Osnova\OsnovaResource|null expected by parameter $resource of Osnova\Services\Subsites\Subsites::getSubsite(). ( Ignorable by Annotation )

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

49
        return $this->getSubsitesService()->getSubsite($id, /** @scrutinizer ignore-type */ $this);
Loading history...
50
    }
51
}
52