Passed
Push — master ( c1377e...33e595 )
by Brian
14:20 queued 09:48
created
includes/reports/class-getpaid-reports-report-items.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports_Report_Items Class.
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
 	 * Retrieves the earning sql.
17 17
 	 *
18 18
 	 */
19
-	public function get_sql( $range ) {
19
+	public function get_sql($range) {
20 20
 		global $wpdb;
21 21
 
22 22
 		$table      = $wpdb->prefix . 'getpaid_invoices';
23 23
 		$table2     = $wpdb->prefix . 'getpaid_invoice_items';
24
-		$clauses    = $this->get_range_sql( $range );
24
+		$clauses    = $this->get_range_sql($range);
25 25
 
26 26
 		$sql        = "SELECT
27 27
 				item.item_name AS item_name,
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 			ORDER BY total DESC
39 39
         ";
40 40
 
41
-		return apply_filters( 'getpaid_items_graphs_get_sql', $sql, $range );
41
+		return apply_filters('getpaid_items_graphs_get_sql', $sql, $range);
42 42
 
43 43
 	}
44 44
 
@@ -48,30 +48,30 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	public function prepare_stats() {
50 50
 		global $wpdb;
51
-		$this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) );
52
-		$this->stats = $this->normalize_stats( $this->stats );
51
+		$this->stats = $wpdb->get_results($this->get_sql($this->get_range()));
52
+		$this->stats = $this->normalize_stats($this->stats);
53 53
 	}
54 54
 
55 55
 	/**
56 56
 	 * Normalizes the report stats.
57 57
 	 *
58 58
 	 */
59
-	public function normalize_stats( $stats ) {
59
+	public function normalize_stats($stats) {
60 60
 		$normalized = array();
61 61
 		$others     = 0;
62 62
 		$did        = 0;
63 63
 
64
-		foreach ( $stats as $stat ) {
64
+		foreach ($stats as $stat) {
65 65
 
66
-			if ( $did > 4 ) {
66
+			if ($did > 4) {
67 67
 
68
-				$others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) );
68
+				$others += wpinv_round_amount(wpinv_sanitize_amount($stat->total));
69 69
 
70 70
 			} else {
71 71
 
72 72
 				$normalized[] = array(
73
-					'total'     => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ),
74
-					'item_name' => strip_tags( $stat->item_name ),
73
+					'total'     => wpinv_round_amount(wpinv_sanitize_amount($stat->total)),
74
+					'item_name' => strip_tags($stat->item_name),
75 75
 				);
76 76
 
77 77
 			}
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 			$did++;
80 80
 		}
81 81
 
82
-		if ( $others > 0 ) {
82
+		if ($others > 0) {
83 83
 
84 84
 			$normalized[] = array(
85
-				'total'     => wpinv_round_amount( wpinv_sanitize_amount( $others ) ),
86
-				'item_name' => esc_html__( 'Others', 'invoicing' ),
85
+				'total'     => wpinv_round_amount(wpinv_sanitize_amount($others)),
86
+				'item_name' => esc_html__('Others', 'invoicing'),
87 87
 			);
88 88
 
89 89
 		}
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function get_data() {
99 99
 
100
-		$data     = wp_list_pluck( $this->stats, 'total' );
101
-		$colors   = array( '#007bff','#28a745','#333333','#c3e6cb','#dc3545','#6c757d', '#00bcd4', '#00695C', '#03a9f4', '#2196f3', '#3f51b5', '#673ab7', '#9c27b0', '#e91e63', '#f44336', '#8bc34a', '#4caf50' );
100
+		$data     = wp_list_pluck($this->stats, 'total');
101
+		$colors   = array('#007bff', '#28a745', '#333333', '#c3e6cb', '#dc3545', '#6c757d', '#00bcd4', '#00695C', '#03a9f4', '#2196f3', '#3f51b5', '#673ab7', '#9c27b0', '#e91e63', '#f44336', '#8bc34a', '#4caf50');
102 102
 
103
-		shuffle( $colors );
103
+		shuffle($colors);
104 104
 
105 105
 		return array(
106 106
 			'data'            => $data,
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 */
116 116
 	public function get_labels() {
117
-		return wp_list_pluck( $this->stats, 'item_name' );
117
+		return wp_list_pluck($this->stats, 'item_name');
118 118
 	}
119 119
 
120 120
 	/**
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 						{
136 136
 							type: 'doughnut',
137 137
 							data: {
138
-								'labels': <?php echo wp_json_encode( $this->get_labels() ); ?>,
139
-								'datasets': [ <?php echo wp_json_encode( $this->get_data() ); ?> ]
138
+								'labels': <?php echo wp_json_encode($this->get_labels()); ?>,
139
+								'datasets': [ <?php echo wp_json_encode($this->get_data()); ?> ]
140 140
 							},
141 141
 							options: {
142 142
 								legend: {
Please login to merge, or discard this patch.