Code Duplication    Length = 19-27 lines in 2 locations

modules/monitor.php 1 location

@@ 119-137 (lines=19) @@
116
	 * @since 4.0.0
117
	 * @return date in YYYY-MM-DD HH:mm:ss format
118
	 */
119
	public function monitor_get_last_downtime() {
120
//		if ( $last_down = get_transient( 'monitor_last_downtime' ) ) {
121
//			return $last_down;
122
//		}
123
124
		$xml = new Jetpack_IXR_Client( array(
125
			'user_id' => get_current_user_id()
126
		) );
127
128
		$xml->query( 'jetpack.monitor.getLastDowntime' );
129
130
		if ( $xml->isError() ) {
131
			return new WP_Error( 'monitor-downtime', $xml->getErrorMessage() );
132
		}
133
134
		set_transient( 'monitor_last_downtime', $xml->getResponse(), 10 * MINUTE_IN_SECONDS );
135
136
		return $xml->getResponse();
137
	}
138
139
}
140

_inc/lib/class.core-rest-api-endpoints.php 1 location

@@ 3455-3481 (lines=27) @@
3452
	 * @param WP_REST_REQUEST $request The request parameters.
3453
	 * @return bool|WP_Error
3454
	 */
3455
	public static function send_mobile_magic_link( $request ) {
3456
		$xml = new Jetpack_IXR_Client(
3457
			array(
3458
				'user_id' => get_current_user_id(),
3459
			)
3460
		);
3461
3462
		$xml->query( 'jetpack.sendMobileMagicLink', array() );
3463
		if ( $xml->isError() ) {
3464
			return new WP_Error(
3465
				'error_sending_mobile_magic_link',
3466
				sprintf(
3467
					'%s: %s',
3468
					$xml->getErrorCode(),
3469
					$xml->getErrorMessage()
3470
				)
3471
			);
3472
		}
3473
3474
		$response = $xml->getResponse();
3475
3476
		return rest_ensure_response(
3477
			array(
3478
				'code' => 'success',
3479
			)
3480
		);
3481
	}
3482
} // class end
3483