Completed
Push — master ( 857471...0927cb )
by Mike
08:18
created

WC_Payment_Gateway_eCheck::payment_fields()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 8
c 1
b 0
f 0
nc 8
nop 0
dl 0
loc 14
rs 9.2
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 13 and the first side effect is on line 3.

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
if ( ! defined( 'ABSPATH' ) ) {
3
	exit;
4
}
5
6
/**
7
 * eCheck Payment Gateway
8
 *
9
 * @since       2.6.0
10
 * @package		WooCommerce/Classes
11
 * @author 		WooThemes
12
 */
13
class WC_Payment_Gateway_eCheck extends WC_Payment_Gateway {
14
15
	/**
16
	 * Builds our payment fields area - including tokenization fields and the actualy payment fields.
17
	 * If tokenization is displayed, just the fields will be displayed.
18
	 * @since 2.6.0
19
	 */
20
	public function payment_fields() {
21
		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout();
22
23
		if ( $display_tokenization ) {
24
			$this->tokenization_script();
25
			$this->saved_payment_methods();
26
		}
27
28
		$this->form();
29
30
		if ( $display_tokenization ) {
31
			$this->save_payment_method_checkbox();
32
		}
33
	}
34
35
	/**
36
	 * Outputs fields for entering eCheck information.
37
	 * @since 2.6.0
38
	 */
39
	public function form() {
40
		$html           = '';
0 ignored issues
show
Unused Code introduced by
$html 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...
41
		$fields         = array();
42
43
		$default_fields = array(
44
			'routing-number' => '<p class="form-row form-row-first">
45
				<label for="' . esc_attr( $this->id ) . '-routing-number">' . __( 'Routing Number', 'woocommerce' ) . ' <span class="required">*</span></label>
46
				<input id="' . esc_attr( $this->id ) . '-routing-number" class="input-text wc-echeck-form-routing-number" type="text" maxlength="9" autocomplete="off" placeholder="•••••••••" name="' . esc_attr( $this->id ) . '-routing-number" />
47
			</p>',
48
			'account-number' => '<p class="form-row form-row-wide">
49
				<label for="' . esc_attr( $this->id ) . '-account-number">' . __( 'Account Number', 'woocommerce' ) . ' <span class="required">*</span></label>
50
				<input id="' . esc_attr( $this->id ) . '-account-number" class="input-text wc-echeck-form-account-number" type="text" autocomplete="off" name="' . esc_attr( $this->id ) . '-account-number" maxlength="17" />
51
			</p>',
52
		);
53
54
		$fields = wp_parse_args( $fields, apply_filters( 'woocommerce_echeck_form_fields', $default_fields, $this->id ) );
55
		?>
56
57
		<fieldset id="<?php echo esc_attr( $this->id ); ?>-cc-form" class='wc-echeck-form'>
58
			<?php do_action( 'woocommerce_echeck_form_start', $this->id ); ?>
59
			<?php
60
				foreach ( $fields as $field ) {
61
					echo $field;
62
				}
63
			?>
64
			<?php do_action( 'woocommerce_echeck_form_end', $this->id ); ?>
65
			<div class="clear"></div>
66
		</fieldset><?php
67
	}
68
69
}
70