Test Setup Failed
Push — master ( 37ef7f...150eda )
by Php Easy Api
03:55
created

SuperClosure::getInstance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Resta\Support;
4
5
use SuperClosure\Serializer;
6
7
class SuperClosure
8
{
9
    /**
10
     * @var null|object
11
     */
12
    private static $singleton;
13
14
    /**
15
     * @return Serializer
16
     */
17
    public static function getInstance()
18
    {
19
        if(is_null(self::$singleton)){
20
            self::$singleton = new Serializer();
21
        }
22
23
        return self::$singleton;
24
    }
25
26
    public static function get($object)
0 ignored issues
show
Unused Code introduced by
The parameter $object is not used and could be removed. ( Ignorable by Annotation )

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

26
    public static function get(/** @scrutinizer ignore-unused */ $object)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
    {
28
29
    }
30
31
    public static function set($data)
32
    {
33
        if(is_callable($data)){
34
            return self::getInstance()->serialize($data);
35
        }
36
        return self::getInstance()->serialize(function() use ($data){
37
            return $data;
38
        });
39
    }
40
}