Completed
Push — branch-7.5 ( 9378b5...5f3718 )
by Jeremy
211:39 queued 203:47
created

Protect   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 18
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A init_listeners() 0 4 1
A maybe_log_failed_login_attempt() 0 6 3
1
<?php
2
3
namespace Automattic\Jetpack\Sync\Modules;
4
5
use Automattic\Jetpack\Constants as Jetpack_Constants;
6
7
/**
8
 * logs bruteprotect failed logins via sync
9
 */
10
class Protect extends \Jetpack_Sync_Module {
11
12
	function name() {
13
		return 'protect';
14
	}
15
16
	function init_listeners( $callback ) {
17
		add_action( 'jpp_log_failed_attempt', array( $this, 'maybe_log_failed_login_attempt' ) );
18
		add_action( 'jetpack_valid_failed_login_attempt', $callback );
19
	}
20
21
	function maybe_log_failed_login_attempt( $failed_attempt ) {
22
		$protect = \Jetpack_Protect_Module::instance();
23
		if ( $protect->has_login_ability() && ! Jetpack_Constants::is_true( 'XMLRPC_REQUEST' ) ) {
24
			do_action( 'jetpack_valid_failed_login_attempt', $failed_attempt );
25
		}
26
	}
27
}
28