Completed
Push — master ( 016764...50d24f )
by judicael
04:08
created

ObjectOperation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 35
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B objectToArray() 0 25 4
1
<?php
2
3
/**
4
 * Manipulate objects
5
 *
6
 * @category  	lib
7
 * @author    	Judicaël Paquet <[email protected]>
8
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
9
 * @license   	https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
10
 * @version   	Release: 1.0.0
11
 * @filesource	https://github.com/las93/venus2
12
 * @link      	https://github.com/las93
13
 */
14
namespace Venus\lib;
15
16
/**
17
 * This class manage object
18
 *
19
 * @category  	lib
20
 * @author    	Judicaël Paquet <[email protected]>
21
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
22
 * @license   	https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
23
 * @version   	Release: 1.0.0
24
 * @filesource	https://github.com/las93/venus2
25
 * @link      	https://github.com/las93
26
 */
27
class ObjectOperation
28
{
29
	/**
30
	 * create an array with an object
31
	 *
32
	 * @access public
33
	 * @param $mObject
34
	 * @return array
35
	 */
36
	public static function objectToArray($mObject) : array
37
	{
38
		if ( is_object($mObject)) {
39
			
40
		    $mObject = (array) $mObject;
41
		}
42
43
44
		if (is_array($mObject)) {
45
46
			$aNew = array();
47
48
			foreach($mObject as $sKey => $mValues) {
49
50
				$sKey = preg_replace("/^\\0(.*)\\0/", "", $sKey);
51
				$aNew[$sKey] = self::objectToArray($mValues);
52
			}
53
		}
54
		else {
55
56
			$aNew = $mObject;
57
		}
58
59
		return $aNew;
60
	}
61
}
62