WC_Payment_Token_eCheck::get_last4()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
eloc 2
nc 1
nop 0
1
<?php
2
3
if ( ! defined( 'ABSPATH' ) ) {
4
	exit; // Exit if accessed directly
5
}
6
7
/**
8
 * WooCommerce eCheck Payment Token.
9
 *
10
 * Representation of a payment token for eChecks.
11
 *
12
 * @class 		WC_Payment_Token_eCheck
13
 * @since		2.6.0
14
 * @category 	PaymentTokens
15
 * @package 	WooCommerce/PaymentTokens
16
 * @author		WooThemes
17
 */
18
class WC_Payment_Token_eCheck extends WC_Payment_Token {
19
20
	/** @protected string Token Type String */
21
	protected $type = 'eCheck';
22
23
 	/**
0 ignored issues
show
Coding Style introduced by
There is some trailing whitespace on this line which should be avoided as per coding-style.
Loading history...
24
	 * Validate eCheck payment tokens.
25
	 *
26
	 * These fields are required by all eCheck payment tokens:
27
	 * last4  - string Last 4 digits of the check
28
	 *
29
	 * @since 2.6.0
30
	 * @return boolean True if the passed data is valid
31
	 */
32
	public function validate() {
33
		if ( false === parent::validate() ) {
34
			return false;
35
		}
36
37
		if ( ! $this->get_last4() ) {
38
			return false;
39
		}
40
		return true;
41
	}
42
43
	/**
44
	 * Get type to display to user.
45
	 * @return string
46
	 */
47
	public function get_display_name() {
48
		return __( 'eCheck', 'woocommerce' );
49
	}
50
51
	/**
52
	 * Returns the last four digits.
53
	 * @since 2.6.0
54
	 * @return string Last 4 digits
55
	 */
56
	public function get_last4() {
57
		return $this->get_meta( 'last4' );
58
	}
59
60
	/**
61
	 * Set the last four digits.
62
	 * @since 2.6.0
63
	 * @param string $last4
64
	 */
65
	public function set_last4( $last4 ) {
66
		$this->add_meta_data( 'last4', $last4, true );
0 ignored issues
show
Documentation introduced by
'last4' is of type string, but the function expects a array.

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...
Documentation introduced by
$last4 is of type string, but the function expects a array.

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...
Documentation introduced by
true is of type boolean, but the function expects a false|array.

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...
67
	}
68
69
}
70