WordPoints_BP_Entity_Message   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 48
loc 48
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_entity() 10 10 2
A get_title() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * Message entity class.
5
 *
6
 * @package WordPoints_BuddyPress
7
 * @since 1.0.0
8
 */
9
10
/**
11
 * Represents a BuddyPress message.
12
 *
13
 * @since 1.0.0
14
 */
15 View Code Duplication
class WordPoints_BP_Entity_Message 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 = 'messages';
21
22
	/**
23
	 * @since 1.0.0
24
	 */
25
	protected $bp_component_table_name = 'messages';
26
27
	/**
28
	 * @since 1.0.0
29
	 */
30
	protected $id_field = 'id';
31
32
	/**
33
	 * @since 1.2.1
34
	 */
35
	protected $id_is_int = true;
36
37
	/**
38
	 * @since 1.0.0
39
	 */
40
	protected $human_id_field = 'subject';
41
42
	/**
43
	 * @since 1.0.0
44
	 */
45
	protected function get_entity( $id ) {
46
47
		$entity = new BP_Messages_Message( $id );
48
49
		if ( ! $entity->id ) {
50
			return false;
51
		}
52
53
		return $entity;
54
	}
55
56
	/**
57
	 * @since 1.0.0
58
	 */
59
	public function get_title() {
60
		return _x( 'Message', 'message entity', 'wordpoints-bp' );
61
	}
62
}
63
64
// EOF
65