original_string: private function generateShippingOptions(array $shipping_options) {
        $response = [];
        $option_index = 1;
  
        foreach ($shipping_options as $option => $prices) {
          array_push($response, ['id' => strval($option_index), 'title' => $option, 'prices' => []]);
  
          // Register prices for the specific shipping option
          foreach ($prices as $service => $price) {
            if ($price < 0) {
              throw new Exception('Invalid negative price passed to "answerShippingQuery"');
            }
  
            $formatted_price = intval($price * 100);
  
            // Selects the most recent shipping option pushed into the array.
            array_push($response[$option_index - 1]['prices'], [
              'label' => $service, 'amount' => $formatted_price
            ]);
          }
  
          $option_index++;
        }
  
        return json_encode($response);
      }
code: private function generateShippingOptions(array $shipping_options) {
        $response = [];
        $option_index = 1;
  
        foreach ($shipping_options as $option => $prices) {
          array_push($response, ['id' => strval($option_index), 'title' => $option, 'prices' => []]);
  
          // Register prices for the specific shipping option
          foreach ($prices as $service => $price) {
            if ($price < 0) {
              throw new Exception('Invalid negative price passed to "answerShippingQuery"');
            }
  
            $formatted_price = intval($price * 100);
  
            // Selects the most recent shipping option pushed into the array.
            array_push($response[$option_index - 1]['prices'], [
              'label' => $service, 'amount' => $formatted_price
            ]);
          }
  
          $option_index++;
        }
  
        return json_encode($response);
      }
code_tokens: private function generateShippingOptions ( array $ shipping_options ) { $ response = [ ] ; $ option_index = 1 ; foreach ( $ shipping_options as $ option => $ prices ) { array_push ( $ response , [ 'id' => strval ( $ option_index ) , 'title' => $ option , 'prices' => [ ] ] ) ; // Register prices for the specific shipping option foreach ( $ prices as $ service => $ price ) { if ( $ price < 0 ) { throw new Exception ( 'Invalid negative price passed to "answerShippingQuery"' ) ; } $ formatted_price = intval ( $ price * 100 ) ; // Selects the most recent shipping option pushed into the array. array_push ( $ response [ $ option_index - 1 ] [ 'prices' ] , [ 'label' => $ service , 'amount' => $ formatted_price ] ) ; } $ option_index ++ ; } return json_encode ( $ response ) ; }
docstring: \brief Generate shipping options to pass to 'answerShippingQuery'.
  @param array $shipping_options The various shipping options represented like PHP data types.
  @return string A JSON string representation of the shipping options.
docstring_tokens: \ brief Generate shipping options to pass to answerShippingQuery .