Completed
Pull Request — master (#9826)
by Mike
10:21
created

WC_Admin_Shipping_Zones::output()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 22
rs 9.2
cc 1
eloc 15
nc 1
nop 0
1
<?php
1 ignored issue
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 18 and the first side effect is on line 12.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Shipping Zones Admin Page
4
 *
5
 * @author      WooThemes
6
 * @category    Admin
7
 * @package     WooCommerce/Admin
8
 * @version     2.5.0
9
 */
10
11
if ( ! defined( 'ABSPATH' ) ) {
12
	exit;
13
}
14
15
/**
16
 * WC_Admin_Shipping_Zones Class.
17
 */
18
class WC_Admin_Shipping_Zones {
19
20
	/**
21
	 * Handles output of the reports page in admin.
22
	 */
23
	public static function output() {
24
        $allowed_countries = WC()->countries->get_allowed_countries();
0 ignored issues
show
Unused Code introduced by
$allowed_countries is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
25
        $continents        = WC()->countries->get_continents();
0 ignored issues
show
Unused Code introduced by
$continents is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
26
27
        // Localize and enqueue our js.
28
		wp_localize_script( 'wc-shipping-zones', 'shippingZonesLocalizeScript', array(
29
            'zones'         => WC_Shipping_Zones::get_zones(),
30
            'default_zone'  => array(
31
				'zone_id'    => 0,
32
				'zone_name'  => '',
33
				'zone_order' => null,
34
			),
35
			'wc_shipping_zones_nonce'  => wp_create_nonce( 'wc_shipping_zones_nonce' ),
36
			'strings'       => array(
37
				'unload_confirmation_msg' => __( 'Your changed data will be lost if you leave this page without saving.', 'woocommerce' ),
38
				'save_failed'             => __( 'Your changes were not saved. Please retry.', 'woocommerce' )
39
			),
40
		) );
41
		wp_enqueue_script( 'wc-shipping-zones' );
42
43
		include_once( 'views/html-admin-page-shipping-zones.php' );
44
	}
45
}
46