Completed
Push — try/capabilities ( 45f305...0b2393 )
by
unknown
06:30
created

Jetpack_Capabilities   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 14 1
A build() 0 3 1
1
<?php
2
/**
3
 * Specifies named capabilities used across Jetpack
4
 *
5
 * These rules give us flexibility to determine which features are enabled, when and for whom
6
 *
7
 * @package Jetpack
8
 */
9
10
use \Automattic\Jetpack\Capabilities;
11
12
class Jetpack_Capabilities {
13
	static function init() {
14
15
		// a legacy capability.
16
		self::build( 'jetpack_activate_modules' )
17
			->require_wp_capability( 'manage_options' );
18
19
		self::build( 'jetpack.recurring-payments.enabled' )
20
			->require_jetpack_is_active()
21
			->require_any( function( $builder ) {
0 ignored issues
show
Documentation introduced by
function ($builder) { ...pgrade_nudge', true); } is of type object<Closure>, but the function expects a object<Automattic\Jetpack\Capabilities\function>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
22
				$builder
23
					->require_jetpack_plan_supports( 'recurring-payments' )
24
					->require_filter( 'jetpack_block_editor_enable_upgrade_nudge', true );
25
			} );
26
	}
27
28
	/**
29
	 * @param string slug The slug for the rule being built
30
	 */
31
	static function build( $slug ) {
32
		return Capabilities::build( $slug );
33
	}
34
}
35
36
add_action( 'init', [ 'Jetpack_Capabilities', 'init' ] );