WordPoints_BP_Entity_Group   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 43
loc 43
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
 * Group entity class.
5
 *
6
 * @package WordPoints_BuddyPress
7
 * @since 1.0.0
8
 */
9
10
/**
11
 * Represents a BuddyPress group.
12
 *
13
 * @since 1.0.0
14
 */
15 View Code Duplication
class WordPoints_BP_Entity_Group 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 = 'groups';
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 $human_id_field = 'name';
36
37
	/**
38
	 * @since 1.0.0
39
	 */
40
	protected function get_entity( $id ) {
41
42
		$entity = groups_get_group( $id );
43
44
		if ( ! $entity->id ) {
45
			return false;
46
		}
47
48
		return $entity;
49
	}
50
51
	/**
52
	 * @since 1.0.0
53
	 */
54
	public function get_title() {
55
		return _x( 'Group', 'group entity', 'wordpoints-bp' );
56
	}
57
}
58
59
// EOF
60