Completed
Push — try/capabilities ( a2fcc0...6ae562 )
by
unknown
08:11
created

BlogStickersRule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Requires that the current blog has at least one of the listed stickers
4
 *
5
 * @package automattic/jetpack-capabilities
6
 */
7
8
namespace Automattic\Jetpack\Capabilities;
9
10
class BlogStickersRule implements Rule {
11
	public function __construct( $stickers ) {
12
		$this->stickers = $stickers;
0 ignored issues
show
Bug introduced by
The property stickers does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
13
	}
14
	public function check( ...$args ) {
15
		return has_any_blog_stickers( $this->stickers, get_current_blog_id() ) ?
16
			new PermissionGranted() :
17
			new PermissionDenied(
18
				sprintf( __( 'Missing required blog sticker', 'jetpack' ) )
19
			);
20
	}
21
}
22