Completed
Push — staging ( 68fed3...485a71 )
by Evan
04:30
created

get_account()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
eloc 9
nc 3
nop 1
dl 14
loc 14
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
/**
4
 *
5
 */
6
class Yikes_Inc_Easy_MailChimp_API_Account extends Yikes_Inc_Easy_MailChimp_API_Abstract_Items {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
8
	/**
9
	 * Get general account info.
10
	 *
11
	 * @author Jeremy Pry
12
	 *
13
	 * @param bool $use_transient Whether to use a transient.
14
	 *
15
	 * @return array|WP_Error
16
	 */
17 View Code Duplication
	public function get_account( $use_transient = true ) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
		$transient_key = 'yikes_eme_account';
19
		$transient     = get_transient( $transient_key );
20
		if ( false !== $transient && $use_transient ) {
21
			return $transient;
22
		}
23
24
		$response = $this->maybe_return_error( $this->get_from_api() );
25
		if ( ! is_wp_error( $response ) ) {
26
			set_transient( $transient_key, $response, HOUR_IN_SECONDS );
27
		}
28
29
		return $response;
30
	}
31
}
32