Completed
Push — master ( 226003...873ec4 )
by J.D.
03:07
created

WordPoints_Entity_Attr_Field   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 21.43 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 2
dl 9
loc 42
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_attr_value_from_entity() 0 3 1
A get_storage_info() 9 9 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
 * Field entity attribute class.
5
 *
6
 * @package wordpoints-hooks-api
7
 * @since   1.0.0
8
 */
9
10
/**
11
 * Represents an entity attribute which is stored as an entity field.
12
 *
13
 * @since 1.0.0
14
 */
15
abstract class WordPoints_Entity_Attr_Field
16
	extends WordPoints_Entity_Attr
17
	implements WordPoints_Entityish_StoredI {
18
19
	/**
20
	 * The storage type for this entity attribute.
21
	 *
22
	 * @since 1.0.0
23
	 *
24
	 * @var string
25
	 */
26
	protected $storage_type;
27
28
	/**
29
	 * The field that this attribute is stored in on the entity.
30
	 *
31
	 * @since 1.0.0
32
	 *
33
	 * @var string
34
	 */
35
	protected $field;
36
37
	/**
38
	 * @since 1.0.0
39
	 */
40
	protected function get_attr_value_from_entity( WordPoints_Entity $entity ) {
41
		return $entity->get_the_attr_value( $this->field );
42
	}
43
	
44
	/**
45
	 * @since 1.0.0
46
	 */
47 View Code Duplication
	public function get_storage_info() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
		return array(
49
			'type' => $this->storage_type,
50
			'info' => array(
51
				'type'  => 'field',
52
				'field' => $this->field,
53
			),
54
		);
55
	}
56
}
57
58
// EOF
59