src/Directions.php
protected function decode( $rsp, $param = 'routes.overview_polyline.points' ){
       
       $needle = metaphone($param);
       
        // get response
        $obj = json_decode( $rsp, true);       
                        
        // flatten array into single level array using 'dot' notation
        $obj_dot = array_dot($obj);
        // create empty response
        $response = [];
        // iterate 
        foreach( $obj_dot as $key => $val){
            
            // Calculate the metaphone key and compare with needle
            $val =  strcmp( metaphone($key, strlen($needle)), $needle) === 0 
                    ? PolyUtil::decode($val) // if matched decode polyline
                    : $val;
            
                array_set($response, $key, $val);
        }        
        

        return json_encode($response, JSON_PRETTY_PRINT) ;

        
        
    }
protected function decode( $rsp, $param = 'routes.overview_polyline.points' ){
       
       $needle = metaphone($param);
       
        // get response
        $obj = json_decode( $rsp, true);       
                        
        // flatten array into single level array using 'dot' notation
        $obj_dot = array_dot($obj);
        // create empty response
        $response = [];
        // iterate 
        foreach( $obj_dot as $key => $val){
            
            // Calculate the metaphone key and compare with needle
            $val =  strcmp( metaphone($key, strlen($needle)), $needle) === 0 
                    ? PolyUtil::decode($val) // if matched decode polyline
                    : $val;
            
                array_set($response, $key, $val);
        }        
        

        return json_encode($response, JSON_PRETTY_PRINT) ;

        
        
    }
protected function decode ( $ rsp , $ param = 'routes.overview_polyline.points' ) { $ needle = metaphone ( $ param ) ; // get response $ obj = json_decode ( $ rsp , true ) ; // flatten array into single level array using 'dot' notation $ obj_dot = array_dot ( $ obj ) ; // create empty response $ response = [ ] ; // iterate  foreach ( $ obj_dot as $ key => $ val ) { // Calculate the metaphone key and compare with needle $ val = strcmp ( metaphone ( $ key , strlen ( $ needle ) ) , $ needle ) === 0 ? PolyUtil :: decode ( $ val ) // if matched decode polyline : $ val ; array_set ( $ response , $ key , $ val ) ; } return json_encode ( $ response , JSON_PRETTY_PRINT ) ; }
Get web wervice polyline parameter being decoded
@param $rsp - string
@param string $param - response key
@return string - JSON
Get web wervice polyline parameter being decoded