DeserializeTrait::deserializeExtra()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace BWC\Share\Object;
4
5
6
trait DeserializeTrait
7
{
8
9
    /**
10
     * @param $data
11
     * @return null|static
12
     */
13
    static function deserialize($data) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
14
        $result = null;
15
        $arr = null;
16
        if (is_string($data)) {
17
            $arr = json_decode($data, true);
18
        } else if (is_array($data)) {
19
            $arr = $data;
20
        } else if(is_object($data)){
21
            $arr = get_object_vars($data);
22
        }
23
        if ($arr) {
24
            /** @var $result DeserializeTrait */
25
            $result = new static();
26
            ObjectHelper::copyExistingProperties($arr, $result);
27
            $result->deserializeExtra($arr);
28
        }
29
        return $result;
30
    }
31
32
    function deserializeExtra($arr) { }
0 ignored issues
show
Unused Code introduced by
The parameter $arr is not used and could be removed.

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

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
34
}