public function convert($type, $data)
    {
        foreach ($data as $k => $v) {
            if (is_array($v)) {
                $data[$k] = $this->convert($type, $v);
            }
        }

        switch (strtolower($type)) {
        case 'array':
            return (array) $data;
            break;
        case 'object':
            return (object) $data;
            break;
        default:
            throw new \Exception('Invalid conversion type given!');
        }
    }
public function convert($type, $data)
    {
        foreach ($data as $k => $v) {
            if (is_array($v)) {
                $data[$k] = $this->convert($type, $v);
            }
        }

        switch (strtolower($type)) {
        case 'array':
            return (array) $data;
            break;
        case 'object':
            return (object) $data;
            break;
        default:
            throw new \Exception('Invalid conversion type given!');
        }
    }
public function convert ( $ type , $ data ) { foreach ( $ data as $ k => $ v ) { if ( is_array ( $ v ) ) { $ data [ $ k ] = $ this -> convert ( $ type , $ v ) ; } } switch ( strtolower ( $ type ) ) { case 'array' : return ( array ) $ data ; break ; case 'object' : return ( object ) $ data ; break ; default : throw new \ Exception ( 'Invalid conversion type given!' ) ; } }
Converts the data into whichever type specified.

@param string $type - [array/object] Convert into a given type
@param mixed  $data - The data to convert

@throws \Exception

@return mixed
Converts the data into whichever type specified .