WordPoints_BP_Entity_Friendship   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get_entity() 0 10 2
A get_entity_human_id() 0 9 1
A get_title() 0 3 1
1
<?php
2
3
/**
4
 * Friendship entity class.
5
 *
6
 * @package WordPoints_BuddyPress
7
 * @since 1.0.0
8
 */
9
10
/**
11
 * Represents a BuddyPress friendship.
12
 *
13
 * @since 1.0.0
14
 */
15
class WordPoints_BP_Entity_Friendship extends WordPoints_BP_Entity {
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...
16
17
	/**
18
	 * @since 1.0.0
19
	 */
20
	protected $bp_component = 'friends';
21
22
	/**
23
	 * @since 1.0.0
24
	 */
25
	protected $id_field = 'id';
26
27
	/**
28
	 * @since 1.2.1
29
	 */
30
	protected $id_is_int = true;
31
32
	/**
33
	 * @since 1.0.0
34
	 */
35
	protected function get_entity( $id ) {
36
37
		$entity = new BP_Friends_Friendship( $id );
38
39
		if ( ! $entity->id ) {
40
			return false;
41
		}
42
43
		return $entity;
44
	}
45
46
	/**
47
	 * @since 1.0.0
48
	 */
49
	protected function get_entity_human_id( $entity ) {
50
51
		return sprintf(
52
			// translators: 1: initiator's display name, 2: friend's display name.
53
			_x( '%1$s + %2$s', 'friendship', 'wordpoints-bp' )
54
			, bp_core_get_user_displayname( $entity->initiator_user_id )
55
			, bp_core_get_user_displayname( $entity->friend_user_id )
56
		);
57
	}
58
59
	/**
60
	 * @since 1.0.0
61
	 */
62
	public function get_title() {
63
		return _x( 'Friendship', 'friendship entity', 'wordpoints-bp' );
64
	}
65
}
66
67
// EOF
68