+ /**
+ * Processes the response body.
+ *
+ * @param string $body request body to process
+ * @return mixed|bool the processed body, or false on error
+ */
+ private function decodeBody( $body ) {
+ $value = json_decode( $body, true );
+ return ( json_last_error() === JSON_ERROR_NONE ) ? $value : false;
+ }
+
+ /**
+ * Prepares the request body (the "value" portion of our key/value store) for transmission.
+ *
+ * @param string $body request body to prepare
+ * @return string the prepared body, or an empty string on error
+ * @throws LogicException
+ */
+ private function encodeBody( $body ) {
+ $value = json_encode( $body );
+ if ( $value === false ) {
+ throw new InvalidArgumentException( __METHOD__ . ": body could not be encoded." );
+ }
+ return $value;
+ }
+