public function arrayToObject($array)
    {
        $object = new \stdClass();
        foreach ($array as $k => $v) {
            if (is_array($v)) {
                // load nested elements
                $v = $this->arrayToObject($v);
            }
            $object->{$k} = $v;
        }

        return $object;
    }