Passed
Push — master ( ae1644...093b58 )
by Brian
04:25
created
includes/geolocation/class-getpaid-maxmind-database-service.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -13,154 +13,154 @@
 block discarded – undo
13 13
  */
14 14
 class GetPaid_MaxMind_Database_Service {
15 15
 
16
-	/**
17
-	 * The name of the MaxMind database to utilize.
18
-	 */
19
-	const DATABASE = 'GeoLite2-Country';
20
-
21
-	/**
22
-	 * The extension for the MaxMind database.
23
-	 */
24
-	const DATABASE_EXTENSION = '.mmdb';
25
-
26
-	/**
27
-	 * A prefix for the MaxMind database filename.
28
-	 *
29
-	 * @var string
30
-	 */
31
-	private $database_prefix;
32
-
33
-	/**
34
-	 * Class constructor.
35
-	 *
36
-	 * @param string|null $database_prefix A prefix for the MaxMind database filename.
37
-	 */
38
-	public function __construct( $database_prefix ) {
39
-		$this->database_prefix = $database_prefix;
40
-	}
41
-
42
-	/**
43
-	 * Fetches the path that the database should be stored.
44
-	 *
45
-	 * @return string The local database path.
46
-	 */
47
-	public function get_database_path() {
48
-		$uploads_dir = wp_upload_dir();
49
-
50
-		$database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/';
51
-		if ( ! empty( $this->database_prefix ) ) {
52
-			$database_path .= $this->database_prefix . '-';
53
-		}
54
-		$database_path .= self::DATABASE . self::DATABASE_EXTENSION;
55
-
56
-		// Filter the geolocation database storage path.
57
-		return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path );
58
-	}
59
-
60
-	/**
61
-	 * Fetches the database from the MaxMind service.
62
-	 *
63
-	 * @param string $license_key The license key to be used when downloading the database.
64
-	 * @return string|WP_Error The path to the database file or an error if invalid.
65
-	 */
66
-	public function download_database( $license_key ) {
67
-
68
-		$download_uri = add_query_arg(
69
-			array(
70
-				'edition_id'  => self::DATABASE,
71
-				'license_key' => urlencode( wpinv_clean( $license_key ) ),
72
-				'suffix'      => 'tar.gz',
73
-			),
74
-			'https://download.maxmind.com/app/geoip_download'
75
-		);
76
-
77
-		// Needed for the download_url call right below.
78
-		require_once ABSPATH . 'wp-admin/includes/file.php';
79
-
80
-		$tmp_archive_path = download_url( esc_url_raw( $download_uri ) );
81
-
82
-		if ( is_wp_error( $tmp_archive_path ) ) {
83
-			// Transform the error into something more informative.
84
-			$error_data = $tmp_archive_path->get_error_data();
85
-			if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) {
86
-				return new WP_Error(
87
-					'getpaid_maxmind_geolocation_database_license_key',
88
-					__( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
89
-				);
90
-			}
91
-
92
-			return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) );
93
-		}
94
-
95
-		// Extract the database from the archive.
96
-		return $this->extract_downloaded_database( $tmp_archive_path );
97
-
98
-	}
99
-
100
-	/**
101
-	 * Extracts the downloaded database.
102
-	 *
103
-	 * @param string $tmp_archive_path The database archive path.
104
-	 * @return string|WP_Error The path to the database file or an error if invalid.
105
-	 */
106
-	protected function extract_downloaded_database( $tmp_archive_path ) {
107
-
108
-		// Extract the database from the archive.
109
-		$tmp_database_path = '';
110
-
111
-		try {
112
-
113
-			$file              = new PharData( $tmp_archive_path );
114
-			$tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION;
115
-
116
-			$file->extractTo(
117
-				dirname( $tmp_archive_path ),
118
-				trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION,
119
-				true
120
-			);
121
-
122
-		} catch ( Exception $exception ) {
123
-			return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
124
-		} finally {
125
-			// Remove the archive since we only care about a single file in it.
126
-			unlink( $tmp_archive_path );
127
-		}
128
-
129
-		return $tmp_database_path;
130
-	}
131
-
132
-	/**
133
-	 * Fetches the ISO country code associated with an IP address.
134
-	 *
135
-	 * @param string $ip_address The IP address to find the country code for.
136
-	 * @return string The country code for the IP address, or empty if not found.
137
-	 */
138
-	public function get_iso_country_code_for_ip( $ip_address ) {
139
-		$country_code = '';
140
-
141
-		if ( ! class_exists( 'MaxMind\Db\Reader' ) ) {
142
-			return $country_code;
143
-		}
144
-
145
-		$database_path = $this->get_database_path();
146
-		if ( ! file_exists( $database_path ) ) {
147
-			return $country_code;
148
-		}
149
-
150
-		try {
151
-			$reader = new MaxMind\Db\Reader( $database_path );
152
-			$data   = $reader->get( $ip_address );
153
-
154
-			if ( isset( $data['country']['iso_code'] ) ) {
155
-				$country_code = $data['country']['iso_code'];
156
-			}
157
-
158
-			$reader->close();
159
-		} catch ( Exception $e ) {
160
-			wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' );
161
-		}
162
-
163
-		return $country_code;
164
-	}
16
+    /**
17
+     * The name of the MaxMind database to utilize.
18
+     */
19
+    const DATABASE = 'GeoLite2-Country';
20
+
21
+    /**
22
+     * The extension for the MaxMind database.
23
+     */
24
+    const DATABASE_EXTENSION = '.mmdb';
25
+
26
+    /**
27
+     * A prefix for the MaxMind database filename.
28
+     *
29
+     * @var string
30
+     */
31
+    private $database_prefix;
32
+
33
+    /**
34
+     * Class constructor.
35
+     *
36
+     * @param string|null $database_prefix A prefix for the MaxMind database filename.
37
+     */
38
+    public function __construct( $database_prefix ) {
39
+        $this->database_prefix = $database_prefix;
40
+    }
41
+
42
+    /**
43
+     * Fetches the path that the database should be stored.
44
+     *
45
+     * @return string The local database path.
46
+     */
47
+    public function get_database_path() {
48
+        $uploads_dir = wp_upload_dir();
49
+
50
+        $database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/';
51
+        if ( ! empty( $this->database_prefix ) ) {
52
+            $database_path .= $this->database_prefix . '-';
53
+        }
54
+        $database_path .= self::DATABASE . self::DATABASE_EXTENSION;
55
+
56
+        // Filter the geolocation database storage path.
57
+        return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path );
58
+    }
59
+
60
+    /**
61
+     * Fetches the database from the MaxMind service.
62
+     *
63
+     * @param string $license_key The license key to be used when downloading the database.
64
+     * @return string|WP_Error The path to the database file or an error if invalid.
65
+     */
66
+    public function download_database( $license_key ) {
67
+
68
+        $download_uri = add_query_arg(
69
+            array(
70
+                'edition_id'  => self::DATABASE,
71
+                'license_key' => urlencode( wpinv_clean( $license_key ) ),
72
+                'suffix'      => 'tar.gz',
73
+            ),
74
+            'https://download.maxmind.com/app/geoip_download'
75
+        );
76
+
77
+        // Needed for the download_url call right below.
78
+        require_once ABSPATH . 'wp-admin/includes/file.php';
79
+
80
+        $tmp_archive_path = download_url( esc_url_raw( $download_uri ) );
81
+
82
+        if ( is_wp_error( $tmp_archive_path ) ) {
83
+            // Transform the error into something more informative.
84
+            $error_data = $tmp_archive_path->get_error_data();
85
+            if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) {
86
+                return new WP_Error(
87
+                    'getpaid_maxmind_geolocation_database_license_key',
88
+                    __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
89
+                );
90
+            }
91
+
92
+            return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) );
93
+        }
94
+
95
+        // Extract the database from the archive.
96
+        return $this->extract_downloaded_database( $tmp_archive_path );
97
+
98
+    }
99
+
100
+    /**
101
+     * Extracts the downloaded database.
102
+     *
103
+     * @param string $tmp_archive_path The database archive path.
104
+     * @return string|WP_Error The path to the database file or an error if invalid.
105
+     */
106
+    protected function extract_downloaded_database( $tmp_archive_path ) {
107
+
108
+        // Extract the database from the archive.
109
+        $tmp_database_path = '';
110
+
111
+        try {
112
+
113
+            $file              = new PharData( $tmp_archive_path );
114
+            $tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION;
115
+
116
+            $file->extractTo(
117
+                dirname( $tmp_archive_path ),
118
+                trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION,
119
+                true
120
+            );
121
+
122
+        } catch ( Exception $exception ) {
123
+            return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
124
+        } finally {
125
+            // Remove the archive since we only care about a single file in it.
126
+            unlink( $tmp_archive_path );
127
+        }
128
+
129
+        return $tmp_database_path;
130
+    }
131
+
132
+    /**
133
+     * Fetches the ISO country code associated with an IP address.
134
+     *
135
+     * @param string $ip_address The IP address to find the country code for.
136
+     * @return string The country code for the IP address, or empty if not found.
137
+     */
138
+    public function get_iso_country_code_for_ip( $ip_address ) {
139
+        $country_code = '';
140
+
141
+        if ( ! class_exists( 'MaxMind\Db\Reader' ) ) {
142
+            return $country_code;
143
+        }
144
+
145
+        $database_path = $this->get_database_path();
146
+        if ( ! file_exists( $database_path ) ) {
147
+            return $country_code;
148
+        }
149
+
150
+        try {
151
+            $reader = new MaxMind\Db\Reader( $database_path );
152
+            $data   = $reader->get( $ip_address );
153
+
154
+            if ( isset( $data['country']['iso_code'] ) ) {
155
+                $country_code = $data['country']['iso_code'];
156
+            }
157
+
158
+            $reader->close();
159
+        } catch ( Exception $e ) {
160
+            wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' );
161
+        }
162
+
163
+        return $country_code;
164
+    }
165 165
 
166 166
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The service class responsible for interacting with MaxMind databases.
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param string|null $database_prefix A prefix for the MaxMind database filename.
37 37
 	 */
38
-	public function __construct( $database_prefix ) {
38
+	public function __construct($database_prefix) {
39 39
 		$this->database_prefix = $database_prefix;
40 40
 	}
41 41
 
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 	public function get_database_path() {
48 48
 		$uploads_dir = wp_upload_dir();
49 49
 
50
-		$database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/';
51
-		if ( ! empty( $this->database_prefix ) ) {
50
+		$database_path = trailingslashit($uploads_dir['basedir']) . 'invoicing/';
51
+		if (!empty($this->database_prefix)) {
52 52
 			$database_path .= $this->database_prefix . '-';
53 53
 		}
54 54
 		$database_path .= self::DATABASE . self::DATABASE_EXTENSION;
55 55
 
56 56
 		// Filter the geolocation database storage path.
57
-		return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path );
57
+		return apply_filters('getpaid_maxmind_geolocation_database_path', $database_path);
58 58
 	}
59 59
 
60 60
 	/**
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
 	 * @param string $license_key The license key to be used when downloading the database.
64 64
 	 * @return string|WP_Error The path to the database file or an error if invalid.
65 65
 	 */
66
-	public function download_database( $license_key ) {
66
+	public function download_database($license_key) {
67 67
 
68 68
 		$download_uri = add_query_arg(
69 69
 			array(
70 70
 				'edition_id'  => self::DATABASE,
71
-				'license_key' => urlencode( wpinv_clean( $license_key ) ),
71
+				'license_key' => urlencode(wpinv_clean($license_key)),
72 72
 				'suffix'      => 'tar.gz',
73 73
 			),
74 74
 			'https://download.maxmind.com/app/geoip_download'
@@ -77,23 +77,23 @@  discard block
 block discarded – undo
77 77
 		// Needed for the download_url call right below.
78 78
 		require_once ABSPATH . 'wp-admin/includes/file.php';
79 79
 
80
-		$tmp_archive_path = download_url( esc_url_raw( $download_uri ) );
80
+		$tmp_archive_path = download_url(esc_url_raw($download_uri));
81 81
 
82
-		if ( is_wp_error( $tmp_archive_path ) ) {
82
+		if (is_wp_error($tmp_archive_path)) {
83 83
 			// Transform the error into something more informative.
84 84
 			$error_data = $tmp_archive_path->get_error_data();
85
-			if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) {
85
+			if (isset($error_data['code']) && $error_data['code'] == 401) {
86 86
 				return new WP_Error(
87 87
 					'getpaid_maxmind_geolocation_database_license_key',
88
-					__( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
88
+					__('The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing')
89 89
 				);
90 90
 			}
91 91
 
92
-			return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) );
92
+			return new WP_Error('getpaid_maxmind_geolocation_database_download', __('Failed to download the MaxMind database.', 'invoicing'));
93 93
 		}
94 94
 
95 95
 		// Extract the database from the archive.
96
-		return $this->extract_downloaded_database( $tmp_archive_path );
96
+		return $this->extract_downloaded_database($tmp_archive_path);
97 97
 
98 98
 	}
99 99
 
@@ -103,27 +103,27 @@  discard block
 block discarded – undo
103 103
 	 * @param string $tmp_archive_path The database archive path.
104 104
 	 * @return string|WP_Error The path to the database file or an error if invalid.
105 105
 	 */
106
-	protected function extract_downloaded_database( $tmp_archive_path ) {
106
+	protected function extract_downloaded_database($tmp_archive_path) {
107 107
 
108 108
 		// Extract the database from the archive.
109 109
 		$tmp_database_path = '';
110 110
 
111 111
 		try {
112 112
 
113
-			$file              = new PharData( $tmp_archive_path );
114
-			$tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION;
113
+			$file              = new PharData($tmp_archive_path);
114
+			$tmp_database_path = trailingslashit(dirname($tmp_archive_path)) . trailingslashit($file->current()->getFilename()) . self::DATABASE . self::DATABASE_EXTENSION;
115 115
 
116 116
 			$file->extractTo(
117
-				dirname( $tmp_archive_path ),
118
-				trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION,
117
+				dirname($tmp_archive_path),
118
+				trailingslashit($file->current()->getFilename()) . self::DATABASE . self::DATABASE_EXTENSION,
119 119
 				true
120 120
 			);
121 121
 
122
-		} catch ( Exception $exception ) {
123
-			return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
122
+		} catch (Exception $exception) {
123
+			return new WP_Error('invoicing_maxmind_geolocation_database_archive', $exception->getMessage());
124 124
 		} finally {
125 125
 			// Remove the archive since we only care about a single file in it.
126
-			unlink( $tmp_archive_path );
126
+			unlink($tmp_archive_path);
127 127
 		}
128 128
 
129 129
 		return $tmp_database_path;
@@ -135,29 +135,29 @@  discard block
 block discarded – undo
135 135
 	 * @param string $ip_address The IP address to find the country code for.
136 136
 	 * @return string The country code for the IP address, or empty if not found.
137 137
 	 */
138
-	public function get_iso_country_code_for_ip( $ip_address ) {
138
+	public function get_iso_country_code_for_ip($ip_address) {
139 139
 		$country_code = '';
140 140
 
141
-		if ( ! class_exists( 'MaxMind\Db\Reader' ) ) {
141
+		if (!class_exists('MaxMind\Db\Reader')) {
142 142
 			return $country_code;
143 143
 		}
144 144
 
145 145
 		$database_path = $this->get_database_path();
146
-		if ( ! file_exists( $database_path ) ) {
146
+		if (!file_exists($database_path)) {
147 147
 			return $country_code;
148 148
 		}
149 149
 
150 150
 		try {
151
-			$reader = new MaxMind\Db\Reader( $database_path );
152
-			$data   = $reader->get( $ip_address );
151
+			$reader = new MaxMind\Db\Reader($database_path);
152
+			$data   = $reader->get($ip_address);
153 153
 
154
-			if ( isset( $data['country']['iso_code'] ) ) {
154
+			if (isset($data['country']['iso_code'])) {
155 155
 				$country_code = $data['country']['iso_code'];
156 156
 			}
157 157
 
158 158
 			$reader->close();
159
-		} catch ( Exception $e ) {
160
-			wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' );
159
+		} catch (Exception $e) {
160
+			wpinv_error_log($e->getMessage(), 'SOURCE: MaxMind GeoLocation');
161 161
 		}
162 162
 
163 163
 		return $country_code;
Please login to merge, or discard this patch.
includes/wpinv-tax-functions.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
216 216
 
217 217
     $initial_tax   = $tax_amount;
218
-	$recurring_tax = 0;
218
+    $recurring_tax = 0;
219 219
 
220 220
     if ( $item->is_recurring() ) {
221
-		$recurring_tax = $recurring_tax_amount;
222
-	}
221
+        $recurring_tax = $recurring_tax_amount;
222
+    }
223 223
 
224
-	return array(
225
-		'name'          => sanitize_text_field( $tax_name ),
226
-		'initial_tax'   => $initial_tax,
227
-		'recurring_tax' => $recurring_tax,
224
+    return array(
225
+        'name'          => sanitize_text_field( $tax_name ),
226
+        'initial_tax'   => $initial_tax,
227
+        'recurring_tax' => $recurring_tax,
228 228
     );
229 229
 
230 230
 }
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
  */
329 329
 function wpinv_should_validate_vat_number() {
330 330
     $validate = wpinv_get_option( 'validate_vat_number' );
331
-	return ! empty( $validate );
331
+    return ! empty( $validate );
332 332
 }
333 333
 
334 334
 function wpinv_sales_tax_for_year( $year = null ) {
Please login to merge, or discard this patch.
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Returns an array of eu states.
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @return array
13 13
  */
14 14
 function getpaid_get_eu_states() {
15
-    return wpinv_get_data( 'eu-states' );
15
+    return wpinv_get_data('eu-states');
16 16
 }
17 17
 
18 18
 /**
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * @return bool
22 22
  */
23
-function getpaid_is_eu_state( $country ) {
24
-    return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_eu_states() ) ? true : false;
23
+function getpaid_is_eu_state($country) {
24
+    return !empty($country) && in_array(strtoupper($country), getpaid_get_eu_states()) ? true : false;
25 25
 }
26 26
 
27 27
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  * @return array
31 31
  */
32 32
 function getpaid_get_gst_states() {
33
-    return array( 'AU', 'NZ', 'CA', 'CN' );
33
+    return array('AU', 'NZ', 'CA', 'CN');
34 34
 }
35 35
 
36 36
 /**
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
  *
39 39
  * @return bool
40 40
  */
41
-function getpaid_is_gst_country( $country ) {
42
-    return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_gst_states() ) ? true : false;
41
+function getpaid_is_gst_country($country) {
42
+    return !empty($country) && in_array(strtoupper($country), getpaid_get_gst_states()) ? true : false;
43 43
 }
44 44
 
45 45
 /**
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function wpinv_use_taxes() {
51 51
 
52
-    $ret = wpinv_get_option( 'enable_taxes', false );
53
-    return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) );
52
+    $ret = wpinv_get_option('enable_taxes', false);
53
+    return (bool) apply_filters('wpinv_use_taxes', !empty($ret));
54 54
 
55 55
 }
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @param WPInv_Invoice $invoice
61 61
  * @return bool
62 62
  */
63
-function wpinv_is_invoice_taxable( $invoice ) {
63
+function wpinv_is_invoice_taxable($invoice) {
64 64
     return $invoice->is_taxable();
65 65
 }
66 66
 
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
  * @param string $country
71 71
  * @return bool
72 72
  */
73
-function wpinv_is_country_taxable( $country ) {
74
-    $is_eu     = getpaid_is_eu_state( $country );
75
-    $is_exempt = ! $is_eu && wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat();
73
+function wpinv_is_country_taxable($country) {
74
+    $is_eu     = getpaid_is_eu_state($country);
75
+    $is_exempt = !$is_eu && wpinv_is_base_country($country) && wpinv_same_country_exempt_vat();
76 76
 
77
-    return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country );
77
+    return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country);
78 78
 
79 79
 }
80 80
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
  * @param WPInv_Item|GetPaid_Form_Item $item
85 85
  * @return bool
86 86
  */
87
-function wpinv_is_item_taxable( $item ) {
87
+function wpinv_is_item_taxable($item) {
88 88
     return '_exempt' != $item->get_vat_rule();
89 89
 }
90 90
 
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
  *
94 94
  * @return bool
95 95
  */
96
-function wpinv_use_store_address_as_tax_base( $tax_rule = false ) {
97
-    $use_base = wpinv_get_option( 'tax_base', 'billing' ) === 'base';
96
+function wpinv_use_store_address_as_tax_base($tax_rule = false) {
97
+    $use_base = wpinv_get_option('tax_base', 'billing') === 'base';
98 98
 
99
-    if ( $tax_rule ) {
100
-        $rules    = getpaid_get_tax_rules( 'tax_base' );
101
-        $use_base = isset( $rules[ $tax_rule ] ) ? 'base' === $rules[ $tax_rule ] : $use_base;
99
+    if ($tax_rule) {
100
+        $rules    = getpaid_get_tax_rules('tax_base');
101
+        $use_base = isset($rules[$tax_rule]) ? 'base' === $rules[$tax_rule] : $use_base;
102 102
     }
103 103
 
104
-    return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base, $tax_rule );
104
+    return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base, $tax_rule);
105 105
 }
106 106
 
107 107
 /**
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
  *
110 110
  * @return bool
111 111
  */
112
-function wpinv_get_vat_same_country_rule( $tax_rule = false ) {
113
-    $rule = wpinv_get_option( 'vat_same_country_rule', 'vat_too' );
112
+function wpinv_get_vat_same_country_rule($tax_rule = false) {
113
+    $rule = wpinv_get_option('vat_same_country_rule', 'vat_too');
114 114
 
115
-    if ( $tax_rule ) {
116
-        $rules = getpaid_get_tax_rules( 'same_country_rule' );
117
-        $rule  = isset( $rules[ $tax_rule ] ) ? $rules[ $tax_rule ] : $rule;
115
+    if ($tax_rule) {
116
+        $rules = getpaid_get_tax_rules('same_country_rule');
117
+        $rule  = isset($rules[$tax_rule]) ? $rules[$tax_rule] : $rule;
118 118
     }
119 119
 
120
-    return (bool) apply_filters( 'wpinv_get_vat_same_country_rule', $rule, $tax_rule );
120
+    return (bool) apply_filters('wpinv_get_vat_same_country_rule', $rule, $tax_rule);
121 121
 }
122 122
 
123 123
 /**
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
  * @return bool
127 127
  */
128 128
 function wpinv_prices_include_tax() {
129
-    $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes';
130
-    return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive );
129
+    $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes';
130
+    return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive);
131 131
 }
132 132
 
133 133
 /**
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
  * @return bool
137 137
  */
138 138
 function wpinv_round_tax_per_tax_rate() {
139
-    $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 );
140
-    return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) );
139
+    $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1);
140
+    return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding));
141 141
 }
142 142
 
143 143
 /**
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
  * @return bool
147 147
  */
148 148
 function wpinv_display_individual_tax_rates() {
149
-    $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual';
150
-    return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual );
149
+    $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual';
150
+    return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual);
151 151
 }
152 152
 
153 153
 /**
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
  * @return float
157 157
  */
158 158
 function wpinv_get_default_tax_rate() {
159
-    $rate = wpinv_get_option( 'tax_rate', 0 );
160
-    return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) );
159
+    $rate = wpinv_get_option('tax_rate', 0);
160
+    return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate));
161 161
 }
162 162
 
163 163
 /**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
  * @return bool
167 167
  */
168 168
 function wpinv_same_country_exempt_vat() {
169
-    return 'no' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' );
169
+    return 'no' == wpinv_get_option('vat_same_country_rule', 'vat_too');
170 170
 }
171 171
 
172 172
 /**
@@ -186,28 +186,28 @@  discard block
 block discarded – undo
186 186
  * @param string $state
187 187
  * @return array
188 188
  */
189
-function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) {
189
+function getpaid_get_item_tax_rates($item, $country = '', $state = '') {
190 190
 
191 191
     // Abort if the item is not taxable.
192
-    if ( ! wpinv_is_item_taxable( $item ) ) {
192
+    if (!wpinv_is_item_taxable($item)) {
193 193
         return array();
194 194
     }
195 195
 
196 196
     // Maybe use the store address.
197
-    if ( wpinv_use_store_address_as_tax_base( $item->get_vat_rule() ) ) {
197
+    if (wpinv_use_store_address_as_tax_base($item->get_vat_rule())) {
198 198
         $country = wpinv_get_default_country();
199 199
         $state   = wpinv_get_default_state();
200 200
     }
201 201
 
202 202
     // Retrieve tax rates.
203
-    $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state );
203
+    $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state);
204 204
 
205 205
     // Fallback to the default tax rates if non were found.
206
-    if ( empty( $tax_rates ) ) {
206
+    if (empty($tax_rates)) {
207 207
         $tax_rates = GetPaid_Tax::get_default_tax_rates();
208 208
     }
209 209
 
210
-    return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state );
210
+    return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state);
211 211
 }
212 212
 
213 213
 /**
@@ -217,22 +217,22 @@  discard block
 block discarded – undo
217 217
  * @param array $rates
218 218
  * @return array
219 219
  */
220
-function getpaid_filter_item_tax_rates( $item, $rates ) {
220
+function getpaid_filter_item_tax_rates($item, $rates) {
221 221
 
222 222
     $tax_class = $item->get_vat_class();
223 223
 
224
-    foreach ( $rates as $i => $rate ) {
224
+    foreach ($rates as $i => $rate) {
225 225
 
226
-        if ( $tax_class == '_reduced' ) {
227
-            $rates[ $i ]['rate'] = empty( $rate['reduced_rate'] ) ? 0 : $rate['reduced_rate'];
226
+        if ($tax_class == '_reduced') {
227
+            $rates[$i]['rate'] = empty($rate['reduced_rate']) ? 0 : $rate['reduced_rate'];
228 228
         }
229 229
 
230
-        if ( $tax_class == '_exempt' ) {
231
-            $rates[ $i ]['rate'] = 0;
230
+        if ($tax_class == '_exempt') {
231
+            $rates[$i]['rate'] = 0;
232 232
         }
233 233
 }
234 234
 
235
-    return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item );
235
+    return apply_filters('getpaid_filter_item_tax_rates', $rates, $item);
236 236
 }
237 237
 
238 238
 /**
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
  * @param array $rates
243 243
  * @return array
244 244
  */
245
-function getpaid_calculate_item_taxes( $amount, $rates ) {
245
+function getpaid_calculate_item_taxes($amount, $rates) {
246 246
 
247 247
     $is_inclusive = wpinv_prices_include_tax();
248
-    $taxes        = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive );
248
+    $taxes        = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive);
249 249
 
250
-    return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates );
250
+    return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates);
251 251
 }
252 252
 
253 253
 /**
@@ -259,17 +259,17 @@  discard block
 block discarded – undo
259 259
  * @param float $recurring_tax_amount
260 260
  * @return array
261 261
  */
262
-function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
262
+function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) {
263 263
 
264
-    $initial_tax   = $tax_amount;
264
+    $initial_tax = $tax_amount;
265 265
 	$recurring_tax = 0;
266 266
 
267
-    if ( $item->is_recurring() ) {
267
+    if ($item->is_recurring()) {
268 268
 		$recurring_tax = $recurring_tax_amount;
269 269
 	}
270 270
 
271 271
 	return array(
272
-		'name'          => sanitize_text_field( $tax_name ),
272
+		'name'          => sanitize_text_field($tax_name),
273 273
 		'initial_tax'   => $initial_tax,
274 274
 		'recurring_tax' => $recurring_tax,
275 275
     );
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
  * @param string $vat_number
283 283
  * @return string
284 284
  */
285
-function wpinv_sanitize_vat_number( $vat_number ) {
286
-    return str_replace( array( ' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
285
+function wpinv_sanitize_vat_number($vat_number) {
286
+    return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
287 287
 }
288 288
 
289 289
 /**
@@ -292,22 +292,22 @@  discard block
 block discarded – undo
292 292
  * @param string $vat_number
293 293
  * @return bool
294 294
  */
295
-function wpinv_regex_validate_vat_number( $vat_number ) {
295
+function wpinv_regex_validate_vat_number($vat_number) {
296 296
 
297
-    $country    = substr( $vat_number, 0, 2 );
298
-    $vatin      = substr( $vat_number, 2 );
299
-    $regexes    = wpinv_get_data( 'vat-number-regexes' );
297
+    $country    = substr($vat_number, 0, 2);
298
+    $vatin      = substr($vat_number, 2);
299
+    $regexes    = wpinv_get_data('vat-number-regexes');
300 300
 
301
-    if ( isset( $regexes[ $country ] ) ) {
301
+    if (isset($regexes[$country])) {
302 302
 
303
-        $regex = $regexes[ $country ];
303
+        $regex = $regexes[$country];
304 304
         $regex = '/^(?:' . $regex . ')$/';
305
-        return 1 === preg_match( $regex, $vatin );
305
+        return 1 === preg_match($regex, $vatin);
306 306
 
307 307
     }
308 308
 
309 309
     // Not an EU state, use filters to validate the number.
310
-    return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number );
310
+    return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number);
311 311
 }
312 312
 
313 313
 /**
@@ -316,29 +316,29 @@  discard block
 block discarded – undo
316 316
  * @param string $vat_number
317 317
  * @return bool
318 318
  */
319
-function wpinv_vies_validate_vat_number( $vat_number ) {
319
+function wpinv_vies_validate_vat_number($vat_number) {
320 320
 
321
-    $country    = substr( $vat_number, 0, 2 );
322
-    $vatin      = substr( $vat_number, 2 );
321
+    $country    = substr($vat_number, 0, 2);
322
+    $vatin      = substr($vat_number, 2);
323 323
 
324 324
     $url        = add_query_arg(
325 325
         array(
326
-            'ms'  => urlencode( $country ),
327
-            'iso' => urlencode( $country ),
328
-            'vat' => urlencode( $vatin ),
326
+            'ms'  => urlencode($country),
327
+            'iso' => urlencode($country),
328
+            'vat' => urlencode($vatin),
329 329
         ),
330 330
         'http://ec.europa.eu/taxation_customs/vies/viesquer.do'
331 331
     );
332 332
 
333
-    $response   = wp_remote_get( $url );
334
-    $response   = wp_remote_retrieve_body( $response );
333
+    $response   = wp_remote_get($url);
334
+    $response   = wp_remote_retrieve_body($response);
335 335
 
336 336
     // Fallback gracefully if the VIES website is down.
337
-    if ( empty( $response ) ) {
337
+    if (empty($response)) {
338 338
         return true;
339 339
     }
340 340
 
341
-    return 1 !== preg_match( '/invalid VAT number/i', $response );
341
+    return 1 !== preg_match('/invalid VAT number/i', $response);
342 342
 
343 343
 }
344 344
 
@@ -349,18 +349,18 @@  discard block
 block discarded – undo
349 349
  * @param string $country
350 350
  * @return bool
351 351
  */
352
-function wpinv_validate_vat_number( $vat_number, $country ) {
352
+function wpinv_validate_vat_number($vat_number, $country) {
353 353
 
354 354
     // In case the vat number does not have a country code...
355
-    $vat_number = wpinv_sanitize_vat_number( $vat_number );
356
-    $_country   = substr( $vat_number, 0, 2 );
357
-    $_country   = $_country == wpinv_country_name( $_country );
355
+    $vat_number = wpinv_sanitize_vat_number($vat_number);
356
+    $_country   = substr($vat_number, 0, 2);
357
+    $_country   = $_country == wpinv_country_name($_country);
358 358
 
359
-    if ( $_country ) {
360
-        $vat_number = strtoupper( $country ) . $vat_number;
359
+    if ($_country) {
360
+        $vat_number = strtoupper($country) . $vat_number;
361 361
     }
362 362
 
363
-    return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number );
363
+    return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number);
364 364
 }
365 365
 
366 366
 /**
@@ -369,39 +369,39 @@  discard block
 block discarded – undo
369 369
  * @return bool
370 370
  */
371 371
 function wpinv_should_validate_vat_number() {
372
-    $validate = wpinv_get_option( 'validate_vat_number' );
373
-	return ! empty( $validate );
372
+    $validate = wpinv_get_option('validate_vat_number');
373
+	return !empty($validate);
374 374
 }
375 375
 
376
-function wpinv_sales_tax_for_year( $year = null ) {
377
-    return wpinv_price( wpinv_get_sales_tax_for_year( $year ) );
376
+function wpinv_sales_tax_for_year($year = null) {
377
+    return wpinv_price(wpinv_get_sales_tax_for_year($year));
378 378
 }
379 379
 
380
-function wpinv_get_sales_tax_for_year( $year = null ) {
380
+function wpinv_get_sales_tax_for_year($year = null) {
381 381
     global $wpdb;
382 382
 
383 383
     // Start at zero
384 384
     $tax = 0;
385 385
 
386
-    if ( ! empty( $year ) ) {
386
+    if (!empty($year)) {
387 387
         $args = array(
388 388
             'post_type'      => 'wpi_invoice',
389
-            'post_status'    => array( 'publish' ),
389
+            'post_status'    => array('publish'),
390 390
             'posts_per_page' => -1,
391 391
             'year'           => $year,
392 392
             'fields'         => 'ids',
393 393
         );
394 394
 
395
-        $payments    = get_posts( $args );
396
-        $payment_ids = implode( ',', $payments );
395
+        $payments    = get_posts($args);
396
+        $payment_ids = implode(',', $payments);
397 397
 
398
-        if ( count( $payments ) > 0 ) {
398
+        if (count($payments) > 0) {
399 399
             $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )";
400
-            $tax = $wpdb->get_var( $sql );
400
+            $tax = $wpdb->get_var($sql);
401 401
         }
402 402
 }
403 403
 
404
-    return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year );
404
+    return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year);
405 405
 }
406 406
 
407 407
 function wpinv_is_cart_taxed() {
@@ -410,34 +410,34 @@  discard block
 block discarded – undo
410 410
 
411 411
 function wpinv_prices_show_tax_on_checkout() {
412 412
     return false; // TODO
413
-    $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() );
413
+    $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes());
414 414
 
415
-    return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret );
415
+    return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret);
416 416
 }
417 417
 
418 418
 function wpinv_display_tax_rate() {
419
-    $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false );
419
+    $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false);
420 420
 
421
-    return apply_filters( 'wpinv_display_tax_rate', $ret );
421
+    return apply_filters('wpinv_display_tax_rate', $ret);
422 422
 }
423 423
 
424 424
 function wpinv_cart_needs_tax_address_fields() {
425
-    if ( ! wpinv_is_cart_taxed() ) {
425
+    if (!wpinv_is_cart_taxed()) {
426 426
         return false;
427 427
     }
428 428
 
429
-    return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
429
+    return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields');
430 430
 }
431 431
 
432
-function wpinv_item_is_tax_exclusive( $item_id = 0 ) {
433
-    $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false );
434
-    return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id );
432
+function wpinv_item_is_tax_exclusive($item_id = 0) {
433
+    $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false);
434
+    return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id);
435 435
 }
436 436
 
437
-function wpinv_currency_decimal_filter( $decimals = 2 ) {
437
+function wpinv_currency_decimal_filter($decimals = 2) {
438 438
     $currency = wpinv_get_currency();
439 439
 
440
-    switch ( $currency ) {
440
+    switch ($currency) {
441 441
         case 'RIAL':
442 442
         case 'JPY':
443 443
         case 'TWD':
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
             break;
447 447
     }
448 448
 
449
-    return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency );
449
+    return apply_filters('wpinv_currency_decimal_count', $decimals, $currency);
450 450
 }
451 451
 
452 452
 function wpinv_tax_amount() {
453 453
     $output = 0.00;
454 454
 
455
-    return apply_filters( 'wpinv_tax_amount', $output );
455
+    return apply_filters('wpinv_tax_amount', $output);
456 456
 }
457 457
 
458 458
 /**
@@ -460,25 +460,25 @@  discard block
 block discarded – undo
460 460
  *
461 461
  * @param string|bool|null $vat_rule
462 462
  */
463
-function getpaid_filter_vat_rule( $vat_rule ) {
463
+function getpaid_filter_vat_rule($vat_rule) {
464 464
 
465
-    if ( empty( $vat_rule ) ) {
465
+    if (empty($vat_rule)) {
466 466
         return 'digital';
467 467
     }
468 468
 
469 469
     return $vat_rule;
470 470
 }
471
-add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' );
471
+add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule');
472 472
 
473 473
 /**
474 474
  * Filters the VAT class to ensure that each item has a VAT class.
475 475
  *
476 476
  * @param string|bool|null $vat_rule
477 477
  */
478
-function getpaid_filter_vat_class( $vat_class ) {
479
-    return empty( $vat_class ) ? '_standard' : $vat_class;
478
+function getpaid_filter_vat_class($vat_class) {
479
+    return empty($vat_class) ? '_standard' : $vat_class;
480 480
 }
481
-add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' );
481
+add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class');
482 482
 
483 483
 /**
484 484
  * Returns a list of all tax classes.
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
     return apply_filters(
491 491
         'getpaid_tax_classes',
492 492
         array(
493
-            '_standard' => __( 'Standard Tax Rate', 'invoicing' ),
494
-            '_reduced'  => __( 'Reduced Tax Rate', 'invoicing' ),
495
-            '_exempt'   => __( 'Tax Exempt', 'invoicing' ),
493
+            '_standard' => __('Standard Tax Rate', 'invoicing'),
494
+            '_reduced'  => __('Reduced Tax Rate', 'invoicing'),
495
+            '_exempt'   => __('Tax Exempt', 'invoicing'),
496 496
         )
497 497
     );
498 498
 
@@ -503,8 +503,8 @@  discard block
 block discarded – undo
503 503
  *
504 504
  * @return array
505 505
  */
506
-function getpaid_get_tax_rules( $return = 'label' ) {
507
-    return wp_list_pluck( GetPaid_Tax::get_all_tax_rules(), $return, 'key' );
506
+function getpaid_get_tax_rules($return = 'label') {
507
+    return wp_list_pluck(GetPaid_Tax::get_all_tax_rules(), $return, 'key');
508 508
 }
509 509
 
510 510
 /**
@@ -513,15 +513,15 @@  discard block
 block discarded – undo
513 513
  * @param string $tax_class
514 514
  * @return string
515 515
  */
516
-function getpaid_get_tax_class_label( $tax_class ) {
516
+function getpaid_get_tax_class_label($tax_class) {
517 517
 
518 518
     $classes = getpaid_get_tax_classes();
519 519
 
520
-    if ( isset( $classes[ $tax_class ] ) ) {
521
-        return sanitize_text_field( $classes[ $tax_class ] );
520
+    if (isset($classes[$tax_class])) {
521
+        return sanitize_text_field($classes[$tax_class]);
522 522
     }
523 523
 
524
-    return sanitize_text_field( $tax_class );
524
+    return sanitize_text_field($tax_class);
525 525
 
526 526
 }
527 527
 
@@ -531,15 +531,15 @@  discard block
 block discarded – undo
531 531
  * @param string $tax_rule
532 532
  * @return string
533 533
  */
534
-function getpaid_get_tax_rule_label( $tax_rule ) {
534
+function getpaid_get_tax_rule_label($tax_rule) {
535 535
 
536 536
     $rules = getpaid_get_tax_rules();
537 537
 
538
-    if ( isset( $rules[ $tax_rule ] ) ) {
539
-        return sanitize_text_field( $rules[ $tax_rule ] );
538
+    if (isset($rules[$tax_rule])) {
539
+        return sanitize_text_field($rules[$tax_rule]);
540 540
     }
541 541
 
542
-    return sanitize_text_field( $tax_rule );
542
+    return sanitize_text_field($tax_rule);
543 543
 
544 544
 }
545 545
 
@@ -550,11 +550,11 @@  discard block
 block discarded – undo
550 550
  * @param string $recurring
551 551
  * @return string
552 552
  */
553
-function getpaid_get_taxable_amount( $item, $recurring = false ) {
553
+function getpaid_get_taxable_amount($item, $recurring = false) {
554 554
 
555 555
     $taxable_amount  = $recurring ? $item->get_recurring_sub_total() : $item->get_sub_total();
556 556
     $taxable_amount -= $recurring ? $item->recurring_item_discount : $item->item_discount;
557
-    $taxable_amount  = max( 0, $taxable_amount );
558
-    return apply_filters( 'getpaid_taxable_amount', $taxable_amount, $item, $recurring );
557
+    $taxable_amount  = max(0, $taxable_amount);
558
+    return apply_filters('getpaid_taxable_amount', $taxable_amount, $item, $recurring);
559 559
 
560 560
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-vat.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_VAT {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the item.
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
     /**
49
-	 * Output the VAT rules settings.
50
-	 *
51
-	 * @param WPInv_Item $item
52
-	 */
49
+     * Output the VAT rules settings.
50
+     *
51
+     * @param WPInv_Item $item
52
+     */
53 53
     public static function output_vat_rules( $item ) {
54 54
         ?>
55 55
 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
     }
88 88
 
89 89
     /**
90
-	 * Output the VAT class settings.
91
-	 *
92
-	 * @param WPInv_Item $item
93
-	 */
90
+     * Output the VAT class settings.
91
+     *
92
+     * @param WPInv_Item $item
93
+     */
94 94
     public static function output_vat_classes( $item ) {
95 95
         ?>
96 96
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,26 +21,26 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         echo "<div class='bsui' style='max-width: 600px;padding-top: 10px;'>";
30 30
 
31
-        do_action( 'wpinv_item_before_vat_metabox', $item );
31
+        do_action('wpinv_item_before_vat_metabox', $item);
32 32
 
33 33
         // Output the vat rules settings.
34
-        do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item );
35
-        self::output_vat_rules( $item );
36
-        do_action( 'wpinv_item_vat_metabox_vat_rules', $item );
34
+        do_action('wpinv_item_vat_metabox_before_vat_rules', $item);
35
+        self::output_vat_rules($item);
36
+        do_action('wpinv_item_vat_metabox_vat_rules', $item);
37 37
 
38 38
         // Output vat class settings.
39
-        do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item );
40
-        self::output_vat_classes( $item );
41
-        do_action( 'wpinv_item_vat_metabox_vat_class', $item );
39
+        do_action('wpinv_item_vat_metabox_before_vat_rules', $item);
40
+        self::output_vat_classes($item);
41
+        do_action('wpinv_item_vat_metabox_vat_class', $item);
42 42
 
43
-        do_action( 'wpinv_item_vat_metabox', $item );
43
+        do_action('wpinv_item_vat_metabox', $item);
44 44
 
45 45
         echo '</div>';
46 46
     }
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param WPInv_Item $item
52 52
 	 */
53
-    public static function output_vat_rules( $item ) {
53
+    public static function output_vat_rules($item) {
54 54
         ?>
55 55
 
56 56
             <div class="wpinv_vat_rules">
57 57
 
58 58
                 <div class="form-group mb-3 row">
59 59
                     <label for="wpinv_vat_rules" class="col-sm-3 col-form-label">
60
-                        <?php esc_html_e( 'Tax Rule', 'invoicing' ); ?>
60
+                        <?php esc_html_e('Tax Rule', 'invoicing'); ?>
61 61
                     </label>
62 62
                     <div class="col-sm-8">
63 63
                         <?php
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
                                 array(
66 66
                                     'id'               => 'wpinv_vat_rules',
67 67
                                     'name'             => 'wpinv_vat_rules',
68
-                                    'placeholder'      => __( 'Select tax rule', 'invoicing' ),
69
-                                    'value'            => $item->get_vat_rule( 'edit' ),
68
+                                    'placeholder'      => __('Select tax rule', 'invoicing'),
69
+                                    'value'            => $item->get_vat_rule('edit'),
70 70
                                     'select2'          => true,
71 71
                                     'data-allow-clear' => 'false',
72 72
                                     'no_wrap'          => true,
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @param WPInv_Item $item
91 91
 	 */
92
-    public static function output_vat_classes( $item ) {
92
+    public static function output_vat_classes($item) {
93 93
         ?>
94 94
 
95 95
             <div class="wpinv_vat_classes">
96 96
 
97 97
                 <div class="form-group mb-3 row">
98 98
                     <label for="wpinv_vat_class" class="col-sm-3 col-form-label">
99
-                        <?php esc_html_e( 'Tax Class', 'invoicing' ); ?>
99
+                        <?php esc_html_e('Tax Class', 'invoicing'); ?>
100 100
                     </label>
101 101
                     <div class="col-sm-8">
102 102
                         <?php
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
                                 array(
105 105
                                     'id'               => 'wpinv_vat_class',
106 106
                                     'name'             => 'wpinv_vat_class',
107
-                                    'placeholder'      => __( 'Select tax class', 'invoicing' ),
108
-                                    'value'            => $item->get_vat_class( 'edit' ),
107
+                                    'placeholder'      => __('Select tax class', 'invoicing'),
108
+                                    'value'            => $item->get_vat_class('edit'),
109 109
                                     'select2'          => true,
110 110
                                     'data-allow-clear' => 'false',
111 111
                                     'no_wrap'          => true,
Please login to merge, or discard this patch.
includes/class-wpinv-euvat.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,27 +55,27 @@
 block discarded – undo
55 55
     public static function vat_rates_settings() {}
56 56
 
57 57
     /**
58
-	 *
59
-	 * @deprecated
60
-	 */
58
+     *
59
+     * @deprecated
60
+     */
61 61
     public static function vat_settings() {}
62 62
 
63 63
     /**
64
-	 *
65
-	 * @deprecated
66
-	 */
64
+     *
65
+     * @deprecated
66
+     */
67 67
     public static function maxmind_folder() {}
68 68
 
69 69
     /**
70
-	 *
71
-	 * @deprecated
72
-	 */
70
+     *
71
+     * @deprecated
72
+     */
73 73
     public static function geoip2_download_database() {}
74 74
 
75 75
     /**
76
-	 *
77
-	 * @deprecated
78
-	 */
76
+     *
77
+     * @deprecated
78
+     */
79 79
     public static function geoip2_download_file() {}
80 80
 
81 81
     /**
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * @deprecated
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
     /**
39 39
      * @deprecated
40 40
      */
41
-    public static function is_eu_state( $country_code ) {
42
-        return getpaid_is_eu_state( $country_code );
41
+    public static function is_eu_state($country_code) {
42
+        return getpaid_is_eu_state($country_code);
43 43
     }
44 44
 
45 45
     /**
46 46
      * @deprecated
47 47
      */
48
-    public static function is_gst_country( $country_code ) {
49
-        return getpaid_is_gst_country( $country_code );
48
+    public static function is_gst_country($country_code) {
49
+        return getpaid_is_gst_country($country_code);
50 50
     }
51 51
 
52 52
     /**
Please login to merge, or discard this patch.
includes/data/eu-states.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @version 1.0.19
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 return array(
12 12
 	'AT',
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -9,31 +9,31 @@
 block discarded – undo
9 9
 defined( 'ABSPATH' ) || exit;
10 10
 
11 11
 return array(
12
-	'AT',
13
-	'BE',
14
-	'BG',
15
-	'HR',
16
-	'CY',
17
-	'CZ',
18
-	'DK',
19
-	'EE',
20
-	'FI',
21
-	'FR',
22
-	'DE',
23
-	'GR',
24
-	'HU',
25
-	'IE',
26
-	'IT',
27
-	'LV',
28
-	'LT',
29
-	'LU',
30
-	'MT',
31
-	'NL',
32
-	'PL',
33
-	'PT',
34
-	'RO',
35
-	'SK',
36
-	'SI',
37
-	'ES',
38
-	'SE',
12
+    'AT',
13
+    'BE',
14
+    'BG',
15
+    'HR',
16
+    'CY',
17
+    'CZ',
18
+    'DK',
19
+    'EE',
20
+    'FI',
21
+    'FR',
22
+    'DE',
23
+    'GR',
24
+    'HU',
25
+    'IE',
26
+    'IT',
27
+    'LV',
28
+    'LT',
29
+    'LU',
30
+    'MT',
31
+    'NL',
32
+    'PL',
33
+    'PT',
34
+    'RO',
35
+    'SK',
36
+    'SI',
37
+    'ES',
38
+    'SE',
39 39
 );
Please login to merge, or discard this patch.
templates/invoice/details-top.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,24 +7,24 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14
-        <?php do_action( 'getpaid_before_invoice_details_top', $invoice ); ?>
14
+        <?php do_action('getpaid_before_invoice_details_top', $invoice); ?>
15 15
 
16 16
         <div class="getpaid-invoice-details-top mb-5">
17 17
             <div class="row">
18 18
                 <div class="col-12 col-sm-6 text-sm-left">
19
-                    <?php do_action( 'getpaid_invoice_details_top_left', $invoice ); ?>
19
+                    <?php do_action('getpaid_invoice_details_top_left', $invoice); ?>
20 20
                 </div>
21 21
 
22 22
                 <div class="col-12 col-sm-6 text-sm-right">
23
-                    <?php do_action( 'getpaid_invoice_details_top_right', $invoice ); ?>
23
+                    <?php do_action('getpaid_invoice_details_top_right', $invoice); ?>
24 24
                 </div>
25 25
             </div>
26 26
         </div>
27 27
 
28
-        <?php do_action( 'getpaid_after_invoice_details_top', $invoice ); ?>
28
+        <?php do_action('getpaid_after_invoice_details_top', $invoice); ?>
29 29
 
30 30
 <?php
Please login to merge, or discard this patch.
templates/invoice/invoice.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
         <?php
19 19
 
20 20
             // Fires when printing the header.
21
-            do_action( 'getpaid_invoice_header', $invoice );
21
+            do_action('getpaid_invoice_header', $invoice);
22 22
 
23 23
             // Print the opening wrapper.
24 24
             echo '<div class="container bg-white border mt-4 mb-4 p-4 position-relative flex-grow-1">';
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
             wpinv_print_errors();
28 28
 
29 29
             // Fires when printing the invoice details.
30
-            do_action( 'getpaid_invoice_details', $invoice );
30
+            do_action('getpaid_invoice_details', $invoice);
31 31
 
32 32
             // Fires when printing the invoice line items.
33
-            do_action( 'getpaid_invoice_line_items', $invoice );
33
+            do_action('getpaid_invoice_line_items', $invoice);
34 34
 
35 35
             // Print the closing wrapper.
36 36
             echo '</div>';
37 37
 
38 38
             // Fires when printing the invoice footer.
39
-            do_action( 'getpaid_invoice_footer', $invoice );
39
+            do_action('getpaid_invoice_footer', $invoice);
40 40
 
41 41
         ?>
42 42
 
Please login to merge, or discard this patch.
includes/api/class-getpaid-rest-report-top-earners-controller.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
  * @since   2.0.0
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 /**
15 15
  * GetPaid REST top earners controller class.
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -18,50 +18,50 @@
 block discarded – undo
18 18
  */
19 19
 class GetPaid_REST_Report_Top_Earners_Controller extends GetPaid_REST_Report_Top_Sellers_Controller {
20 20
 
21
-	/**
22
-	 * Route base.
23
-	 *
24
-	 * @var string
25
-	 */
26
-	protected $rest_base = 'reports/top_earners';
21
+    /**
22
+     * Route base.
23
+     *
24
+     * @var string
25
+     */
26
+    protected $rest_base = 'reports/top_earners';
27 27
 
28
-	/**
29
-	 * Get all data needed for this report and store in the class.
30
-	 */
31
-	protected function query_report_data() {
28
+    /**
29
+     * Get all data needed for this report and store in the class.
30
+     */
31
+    protected function query_report_data() {
32 32
 
33
-		$this->report_data = GetPaid_Reports_Helper::get_invoice_report_data(
34
-			array(
35
-				'data'         => array(
36
-					'quantity'  => array(
37
-						'type'     => 'invoice_item',
38
-						'function' => 'SUM',
39
-						'name'     => 'invoice_item_qty',
40
-					),
41
-					'item_id'   => array(
42
-						'type'     => 'invoice_item',
43
-						'function' => '',
44
-						'name'     => 'invoice_item_id',
45
-					),
46
-					'item_name' => array(
47
-						'type'     => 'invoice_item',
48
-						'function' => '',
49
-						'name'     => 'invoice_item_name',
50
-					),
51
-					'price'     => array(
52
-						'type'     => 'invoice_item',
53
-						'function' => 'SUM',
54
-						'name'     => 'invoice_item_price',
55
-					),
56
-				),
57
-				'group_by'     => 'invoice_item_id',
58
-				'order_by'     => 'invoice_item_price DESC',
59
-				'query_type'   => 'get_results',
60
-				'limit'        => 10,
61
-				'filter_range' => $this->report_range,
62
-			)
63
-		);
33
+        $this->report_data = GetPaid_Reports_Helper::get_invoice_report_data(
34
+            array(
35
+                'data'         => array(
36
+                    'quantity'  => array(
37
+                        'type'     => 'invoice_item',
38
+                        'function' => 'SUM',
39
+                        'name'     => 'invoice_item_qty',
40
+                    ),
41
+                    'item_id'   => array(
42
+                        'type'     => 'invoice_item',
43
+                        'function' => '',
44
+                        'name'     => 'invoice_item_id',
45
+                    ),
46
+                    'item_name' => array(
47
+                        'type'     => 'invoice_item',
48
+                        'function' => '',
49
+                        'name'     => 'invoice_item_name',
50
+                    ),
51
+                    'price'     => array(
52
+                        'type'     => 'invoice_item',
53
+                        'function' => 'SUM',
54
+                        'name'     => 'invoice_item_price',
55
+                    ),
56
+                ),
57
+                'group_by'     => 'invoice_item_id',
58
+                'order_by'     => 'invoice_item_price DESC',
59
+                'query_type'   => 'get_results',
60
+                'limit'        => 10,
61
+                'filter_range' => $this->report_range,
62
+            )
63
+        );
64 64
 
65
-	}
65
+    }
66 66
 
67 67
 }
Please login to merge, or discard this patch.
includes/class-wpinv-api.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since    1.0.19
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * The main API class
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         $this->invoice_counts = new GetPaid_REST_Report_Invoice_Counts_Controller();
97 97
 
98 98
         // Fires after loading the rest api.
99
-        do_action( 'getpaid_rest_api_loaded', $this );
99
+        do_action('getpaid_rest_api_loaded', $this);
100 100
     }
101 101
 
102 102
 }
Please login to merge, or discard this patch.