WordPoints_BP_Entity_Message_Recipients   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get_title() 0 3 1
A get_related_entity_ids() 0 10 2
A get_storage_info() 0 12 1
1
<?php
2
3
/**
4
 * Message recipients entity relationship class.
5
 *
6
 * @package WordPoints_BuddyPress
7
 * @since 1.0.0
8
 */
9
10
/**
11
 * Defines the relationship between a message and its recipients.
12
 *
13
 * @since 1.0.0
14
 */
15
class WordPoints_BP_Entity_Message_Recipients
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
	extends WordPoints_Entity_Relationship
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
Coding Style introduced by
Expected 0 spaces between "WordPoints_Entity_Relationship" and comma; 1 found
Loading history...
17
	implements WordPoints_Entityish_StoredI {
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
18
19
	/**
20
	 * @since 1.0.0
21
	 */
22
	protected $primary_entity_slug = 'bp_message';
23
24
	/**
25
	 * @since 1.0.0
26
	 */
27
	protected $related_entity_slug = 'user{}';
28
29
	/**
30
	 * @since 1.0.0
31
	 */
32
	public function get_title() {
33
		return _x( 'Recipients', 'message entity', 'wordpoints-bp' );
34
	}
35
36
	/**
37
	 * @since 1.0.0
38
	 */
39
	protected function get_related_entity_ids( WordPoints_Entity $entity ) {
40
41
		$message = new BP_Messages_Message( $entity->get_the_id() );
42
43
		if ( ! $message->id ) {
44
			return false;
45
		}
46
47
		return $message->get_recipients();
48
	}
49
50
	/**
51
	 * @since 1.0.0
52
	 */
53
	public function get_storage_info() {
54
55
		return array(
56
			'type' => 'db',
57
			'info' => array(
58
				'type'             => 'table',
59
				'table_name'       => buddypress()->messages->table_name_recipients,
60
				'primary_id_field' => 'thread_id',
61
				'related_id_field' => 'user_id',
62
			),
63
		);
64
	}
65
}
66
67
// EOF
68