Completed
Push — jetpack-fusion-mock-files ( e51750...3b1561 )
by
unknown
13:31
created

Jetpack_Google_Analytics_Options   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 13
lcom 1
cbo 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A get_option() 0 4 2
A get_tracking_code() 0 3 1
A has_tracking_code() 0 4 1
A anonymize_ip_is_enabled() 0 3 1
A track_purchases_is_enabled() 0 3 1
A track_add_to_cart_is_enabled() 0 3 1
A enhanced_ecommerce_tracking_is_enabled() 0 3 1
A track_remove_from_cart_is_enabled() 0 3 1
A track_product_impressions_is_enabled() 0 3 1
A track_product_clicks_is_enabled() 0 3 1
A track_product_detail_view_is_enabled() 0 3 1
A track_checkout_started_is_enabled() 0 3 1
1
<?php
2
3
/**
4
* Jetpack_Google_Analytics_Options provides a single interface to module options
5
*
6
* @author allendav 
7
*/
8
9
/**
10
* Bail if accessed directly
11
*/
12
if ( ! defined( 'ABSPATH' ) ) {
13
	exit;
14
}
15
16
class Jetpack_Google_Analytics_Options {
17
	public static function get_option( $option_name, $default = false ) {
18
		$o = get_option( 'jetpack_wga' );
19
		return isset( $o[ $option_name ] ) ? $o[ $option_name ] : $default;
20
	}
21
22
	public static function get_tracking_code() {
23
		return self::get_option( 'code', '' );
0 ignored issues
show
Documentation introduced by
'' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
24
	}
25
26
	public static function has_tracking_code() {
27
		$code = self::get_tracking_code();
28
		return ! empty( $code );
29
	}
30
31
	// Options used by both legacy and universal analytics
32
	public static function anonymize_ip_is_enabled() {
33
		return self::get_option( 'anonymize_ip' );
34
	}
35
36
	// eCommerce options used by both legacy and universal analytics
37
	public static function track_purchases_is_enabled() {
38
		return self::get_option( 'ec_track_purchases' );
39
	}
40
41
	public static function track_add_to_cart_is_enabled() {
42
		return self::get_option( 'ec_track_add_to_cart' );
43
	}
44
45
	// Enhanced eCommerce options
46
	public static function enhanced_ecommerce_tracking_is_enabled() {
47
		return self::get_option( 'enh_ec_tracking' );
48
	}
49
50
	public static function track_remove_from_cart_is_enabled() {
51
		return self::get_option( 'enh_ec_track_remove_from_cart' );
52
	}
53
54
	public static function track_product_impressions_is_enabled() {
55
		return self::get_option( 'enh_ec_track_prod_impression' );
56
	}
57
58
	public static function track_product_clicks_is_enabled() {
59
		return self::get_option( 'enh_ec_track_prod_click' );
60
	}
61
62
	public static function track_product_detail_view_is_enabled() {
63
		return self::get_option( 'enh_ec_track_prod_detail_view' );
64
	}
65
66
	public static function track_checkout_started_is_enabled() {
67
		return self::get_option( 'enh_ec_track_checkout_started' );
68
	}
69
}
70
71