Code Duplication    Length = 10-10 lines in 2 locations

projects/packages/connection/src/class-tokens.php 1 location

@@ 206-215 (lines=10) @@
203
			$json = false;
204
		}
205
206
		if ( 200 !== $code || ! empty( $json->error ) ) {
207
			if ( empty( $json->error ) ) {
208
				return new WP_Error( 'unknown', '', $code );
209
			}
210
211
			/* translators: Error description string. */
212
			$error_description = isset( $json->error_description ) ? sprintf( __( 'Error Details: %s', 'jetpack' ), (string) $json->error_description ) : '';
213
214
			return new WP_Error( (string) $json->error, $error_description, $code );
215
		}
216
217
		if ( empty( $json->access_token ) || ! is_scalar( $json->access_token ) ) {
218
			return new WP_Error( 'access_token', '', $code );

projects/packages/connection/src/class-manager.php 1 location

@@ 2303-2312 (lines=10) @@
2300
			$json = false;
2301
		}
2302
2303
		if ( 200 !== $code ) {
2304
			if ( empty( $json->code ) ) {
2305
				return new WP_Error( 'unknown', '', $code );
2306
			}
2307
2308
			/* translators: Error description string. */
2309
			$error_description = isset( $json->message ) ? sprintf( __( 'Error Details: %s', 'jetpack' ), (string) $json->message ) : '';
2310
2311
			return new WP_Error( (string) $json->code, $error_description, $code );
2312
		}
2313
2314
		if ( empty( $json->jetpack_secret ) || ! is_scalar( $json->jetpack_secret ) ) {
2315
			return new WP_Error( 'jetpack_secret', '', $code );