Test Setup Failed
Push — master ( ec418a...867dc1 )
by Php Easy Api
03:31
created

SerializeClassProcess   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 4 1
A getInstance() 0 7 2
A set() 0 4 1
1
<?php
2
3
namespace Resta\Support;
4
5
use SuperClosure\Serializer;
6
7
class SerializeClassProcess
8
{
9
    /**
10
     * @var array
11
     */
12
    private static $serializes = [];
0 ignored issues
show
introduced by
The private property $serializes is not used, and could be removed.
Loading history...
13
14
    /**
15
     * @var null|object
16
     */
17
    private static $singleton;
18
19
    /**
20
     * @return object|Serializer|null
21
     */
22
    private static function getInstance()
23
    {
24
        if(is_null(self::$singleton)){
25
            self::$singleton = new Serializer();
26
        }
27
28
        return self::$singleton;
29
    }
30
31
    /**
32
     * @param $key
33
     * @return mixed
34
     */
35
    public static function get($key)
36
    {
37
        $closureResolve = self::getInstance()->unserialize($key);
38
        return $closureResolve();
39
    }
40
41
    /**
42
     * @param $key
43
     * @return string
44
     */
45
    public static function set($key)
46
    {
47
        return self::getInstance()->serialize(function() use($key){
48
            return app()->resolve($key);
49
        });
50
    }
51
}