private static function arrayToObject(array $array)
    {
        $is_object = false;

        foreach ($array as $key => &$value) {
            if (is_array($value)) {
                $value = self::arrayToObject($value);
            }

            if (is_string($key)) {
                $is_object = true;
            }
        }

        return $is_object ? (object) $array : $array;
    }