Completed
Pull Request — master (#54)
by Jamie
03:26
created

FrmDbDeprecated   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 128
Duplicated Lines 8.59 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 11
loc 128
rs 10
c 0
b 0
f 0
wmc 14
lcom 0
cbo 1

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 2
A upgrade() 0 6 1
A collation() 0 6 1
A uninstall() 0 6 1
A get_where_clause_and_values() 0 4 1
A parse_where_from_array() 0 4 1
A get_count() 0 5 1
A get_var() 0 5 1
A get_col() 0 5 1
A get_row() 0 5 1
A get_results() 0 5 1
A append_where_is() 0 5 1
A get_associative_array_results() 0 5 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
 * Class FrmDbDeprecated
5
 *
6
 * @since 2.03.05
7
 */
8
class FrmDbDeprecated {
9
10
	var $fields;
11
	var $forms;
12
	var $entries;
13
	var $entry_metas;
14
15 View Code Duplication
	public function __construct() {
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...
16
		if ( ! defined( 'ABSPATH' ) ) {
17
			die( 'You are not allowed to call this page directly.' );
18
		}
19
20
		global $wpdb;
21
		$this->fields      = $wpdb->prefix . 'frm_fields';
22
		$this->forms       = $wpdb->prefix . 'frm_forms';
23
		$this->entries     = $wpdb->prefix . 'frm_items';
24
		$this->entry_metas = $wpdb->prefix . 'frm_item_metas';
25
	}
26
27
	/**
28
	 * @deprecated 2.03.05
29
	 */
30
	public function upgrade( $old_db_version = false ) {
31
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::upgrade( $old_db_version )' );
32
33
		$db = new FrmDb();
34
		$db->upgrade( $old_db_version );
35
	}
36
37
	/**
38
	 * @deprecated 2.03.05
39
	 */
40
	public function collation() {
41
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::collation()' );
42
43
		$db = new FrmDb();
44
		$db->collation();
45
	}
46
47
	/**
48
	 * @deprecated 2.03.05
49
	 */
50
	public function uninstall() {
51
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::uninstall()' );
52
53
		$db = new FrmDb();
54
		$db->uninstall();
55
	}
56
57
	/**
58
	 * @deprecated 2.03.05
59
	 */
60
	public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
61
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::get_where_clause_and_values( $args, $starts_with )' );
62
		FrmDb::get_where_clause_and_values( $args, $starts_with );
63
	}
64
65
	/**
66
	 * @deprecated 2.03.05
67
	 */
68
	public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
69
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::parse_where_from_array( $args, $base_where, $where, $values )' );
70
		FrmDb::parse_where_from_array( $args, $base_where, $where, $values );
71
	}
72
73
	/**
74
	 * @deprecated 2.03.05
75
	 */
76
	public static function get_count( $table, $where = array(), $args = array() ) {
77
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::get_count' );
78
79
		return FrmDb::get_count( $table, $where, $args );
80
	}
81
82
	/**
83
	 * @deprecated 2.03.05
84
	 */
85
	public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
86
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::get_var' );
87
88
		return FrmDb::get_var( $table, $where, $field, $args, $limit, $type );
89
	}
90
91
	/**
92
	 * @deprecated 2.03.05
93
	 */
94
	public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
95
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::get_col' );
96
97
		return FrmDb::get_col( $table, $where, $field, $args, $limit );
98
	}
99
100
	/**
101
	 * @deprecated 2.03.05
102
	 */
103
	public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
104
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::get_row' );
105
106
		return FrmDb::get_row( $table, $where, $fields, $args );
107
	}
108
109
	/**
110
	 * @deprecated 2.03.05
111
	 */
112
	public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
113
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::get_results' );
114
115
		return FrmDb::get_results( $table, $where, $fields, $args );
116
	}
117
118
	/**
119
	 * @deprecated 2.03.05
120
	 */
121
	public static function append_where_is( $where_is ) {
122
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::append_where_is' );
123
124
		return FrmDb::append_where_is( $where_is );
125
	}
126
127
	/**
128
	 * @deprecated 2.03.05
129
	 */
130
	public static function get_associative_array_results( $columns, $table, $where ) {
131
		_deprecated_function( __FUNCTION__, '2.03.05', 'FrmDb::get_associative_array_results' );
132
133
		return FrmDb::get_associative_array_results( $columns, $table, $where );
134
	}
135
}
136