We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4ea1fd2 commit 3524350Copy full SHA for 3524350
src/Filesystem/Converter.php
@@ -23,14 +23,25 @@ final class Converter
23
*
24
* @access public
25
* @param array $array
26
- * @return object
+ * @param bool $stric, Convert all sub-items
27
+ * @return mixed
28
*/
- public static function toObject($array)
29
+ public static function toObject($array, $stric = false)
30
{
- return (object)Json::decode(
31
- Json::encode($array),
32
- false
33
- );
+ if ( !TypeCheck::isArray($array) ) {
+ return $array;
+ }
34
+ if ( $stric ) {
35
+ return (object)Json::decode(
36
+ Json::encode($array),
37
+ false
38
+ );
39
40
+ $obj = new \stdClass;
41
+ foreach ( $array as $item => $val ) {
42
+ $obj->{$item} = $val;
43
44
+ return (object)$obj;
45
}
46
47
/**
0 commit comments