Code Duplication    Length = 20-22 lines in 2 locations

src/Utility/ObjectUtils.php 2 locations

@@ 51-72 (lines=22) @@
48
        return $deep ? $this->toDeepArray($object) : $this->toShallowArray($object);
49
    }
50
51
    private function toDeepArray($object)
52
    {
53
        $array = [];
54
55
        if ($this->isDateTimeExtensionObject($object)) {
56
            return $this->parseDateTimeExtensionObject($object);
57
        }
58
59
        $vars = $this->getAllObjectVarsOrArrayProperties($object);
60
61
        foreach ($vars as $property => $value) {
62
            if (is_object($value) || is_array($value)) {
63
                $array[$property] = $this->toDeepArray($value);
64
            } elseif (is_resource($value)) {
65
                $array[$property] = (string)$value;
66
            } else {
67
                $array[$property] = $value;
68
            }
69
        }
70
71
        return $array;
72
    }
73
74
    private function isDateTimeExtensionObject($object)
75
    {
@@ 120-139 (lines=20) @@
117
        return $vars;
118
    }
119
120
    private function toShallowArray($object)
121
    {
122
        $array = [];
123
124
        if ($this->isDateTimeExtensionObject($object)) {
125
            return $this->parseDateTimeExtensionObject($object);
126
        }
127
128
        foreach ($object as $property => $value) {
129
            if (is_object($value) || is_array($value)) {
130
                $array[$property] = $this->toShallowArray($value);
131
            } elseif (is_resource($value)) {
132
                $array[$property] = (string)$value;
133
            } else {
134
                $array[$property] = $value;
135
            }
136
        }
137
138
        return $array;
139
    }
140
}
141