| Conditions | 5 |
| Paths | 8 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | static function deserialize($data) { |
||
|
|
|||
| 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 | |||
| 34 | } |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.