Completed
Push — develop ( b1cd3a...64c22d )
by J.D.
01:59
created

WordPoints_BP_Hook_Action_Avatar   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A should_fire() 0 8 2
1
<?php
2
3
/**
4
 * Avatar hook action class.
5
 *
6
 * @package WordPoints_BuddyPress
7
 * @since   1.2.1
8
 */
9
10
/**
11
 * Bootstrap for actions relating to avatars.
12
 *
13
 * Avatars are supported by both users and groups, so we are able to use the same
14
 * action classes for both. This class provides some bootstrap to help with that.
15
 *
16
 * @since 1.2.1
17
 */
18
class WordPoints_BP_Hook_Action_Avatar extends WordPoints_Hook_Action {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
19
20
	/**
21
	 * The type of object to fire for.
22
	 *
23
	 * @since 1.2.1
24
	 *
25
	 * @var string
26
	 */
27
	protected $bp_avatar_object_type = 'user';
28
29
	/**
30
	 * @since 1.2.1
31
	 */
32
	public function __construct( $slug, array $action_args, array $args = array() ) {
33
34
		if ( isset( $args['bp_avatar_object_type'] ) ) {
35
			$this->bp_avatar_object_type = $args['bp_avatar_object_type'];
36
		}
37
38
		parent::__construct( $slug, $action_args, $args );
39
	}
40
41
	/**
42
	 * @since 1.2.1
43
	 */
44
	public function should_fire() {
1 ignored issue
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
45
46
		if ( null === $this->get_arg_value( $this->bp_avatar_object_type ) ) {
47
			return false;
48
		}
49
50
		return parent::should_fire();
51
	}
52
}
53
54
// EOF
55