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

@@ 2127-2136 (lines=10) @@
2124
			$json = false;
2125
		}
2126
2127
		if ( 200 !== $code ) {
2128
			if ( empty( $json->code ) ) {
2129
				return new WP_Error( 'unknown', '', $code );
2130
			}
2131
2132
			/* translators: Error description string. */
2133
			$error_description = isset( $json->message ) ? sprintf( __( 'Error Details: %s', 'jetpack' ), (string) $json->message ) : '';
2134
2135
			return new WP_Error( (string) $json->code, $error_description, $code );
2136
		}
2137
2138
		if ( empty( $json->jetpack_secret ) || ! is_scalar( $json->jetpack_secret ) ) {
2139
			return new WP_Error( 'jetpack_secret', '', $code );