Passed
Push — master ( b91050...6fb96f )
by Jens
02:59
created

ValuelistService::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by: Jens
4
 * Date: 12-10-2017
5
 */
6
7
namespace CloudControl\Cms\services;
8
9
10
use CloudControl\Cms\storage\entities\Valuelist;
11
use CloudControl\Cms\storage\Storage;
12
13
class ValuelistService
14
{
15
    private static $instance;
16
    /**
17
     * @var Storage
18
     */
19
    protected $storage;
20
21
    /**
22
     * FileService constructor.
23
     */
24
    protected function __construct()
25
    {}
26
27
    /**
28
     * @return ValuelistService
29
     */
30
    public static function getInstance()
31
    {
32
        if (!self::$instance instanceof ValuelistService) {
33
            self::$instance = new ValuelistService();
34
        }
35
        return self::$instance;
36
    }
37
38
    /**
39
     * @param $slug
40
     * @return Valuelist
41
     */
42
    public static function get($slug)
43
    {
44
        $instance = self::getInstance();
45
        $valuelist = $instance->storage->getValuelists()->getValuelistBySlug($slug);
46
        return new Valuelist($valuelist);
0 ignored issues
show
Documentation introduced by
$valuelist is of type object<CloudControl\Cms\...ntities\Valuelist>|null, but the function expects a object<stdClass>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
47
48
    }
49
50
    /**
51
     * @param Storage $storage
52
     */
53
    public function init(Storage $storage)
54
    {
55
        $this->storage = $storage;
56
    }
57
}