Test Failed
Push — issues/2912 ( 47fdf9...1e5343 )
by Ravinder
09:11
created

Give_DB_Sequential_Donations::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Sequential Donation DB
4
 *
5
 * @package     Give
6
 * @subpackage  Classes/Give_DB_Sequential_Donations
7
 * @copyright   Copyright (c) 2018, WordImpress
8
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
9
 * @since       2.1.0
10
 */
11
12
// Exit if accessed directly.
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * Give_DB_Sequential_Donations Class
19
 *
20
 * This class is for interacting with the log database table.
21
 *
22
 * @since 2.1.0
23
 */
24
class Give_DB_Sequential_Donations extends Give_DB {
25
26
	/**
27
	 * Give_DB_Sequential_Donations constructor.
28
	 *
29
	 * Set up the Give DB Donor class.
30
	 *
31
	 * @since  2.1.0
32
	 * @access public
33
	 */
34 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...
35
		/* @var WPDB $wpdb */
36
		global $wpdb;
37
38
		$this->table_name  = $wpdb->prefix . 'give_sequential_donations';
39
		$this->primary_key = 'id';
40
		$this->version     = '1.0';
41
42
		// Install table.
43
		$this->register_table();
44
45
		parent::__construct();
46
	}
47
48
	/**
49
	 * Get columns and formats
50
	 *
51
	 * @since  2.1.0
52
	 * @access public
53
	 *
54
	 * @return array  Columns and formats.
55
	 */
56
	public function get_columns() {
57
		return array(
58
			'id'         => '%d',
59
			'payment_id' => '%s',
60
		);
61
	}
62
63
	/**
64
	 * Get default column values
65
	 *
66
	 * @since  2.1.0
67
	 * @access public
68
	 *
69
	 * @return array  Default column values.
70
	 */
71
	public function get_column_defaults() {
72
		return array(
73
			'id'         => 0,
74
			'payment_id' => '',
75
		);
76
	}
77
78
79
	/**
80
	 * Create the table
81
	 *
82
	 * @since  2.1.0
83
	 * @access public
84
	 *
85
	 * @return void
86
	 */
87 View Code Duplication
	public function create_table() {
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...
88
		global $wpdb;
89
		$charset_collate = $wpdb->get_charset_collate();
90
91
		$sql = "CREATE TABLE {$this->table_name} (
92
        id bigint(20) NOT NULL AUTO_INCREMENT,
93
        payment_id bigint(20) NOT NULL,
94
        PRIMARY KEY  (id)
95
        ) {$charset_collate};";
96
97
		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
98
		dbDelta( $sql );
99
100
		update_option( $this->table_name . '_db_version', $this->version );
101
	}
102
}
103