Completed
Branch BUG-9548-transaction-completio... (b1c41e)
by
unknown
519:42 queued 503:28
created

InlineAddressFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 38
loc 38
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B format() 24 24 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace EventEspresso\core\services\address\formatters;
3
4
if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
	exit( 'No direct script access allowed' );
6
}
7
8
9
10
/**
11
 * Class InlineAddressFormatter
12
 * This class will format an address and add commas in appropriate places
13
 *
14
 * @package       Event Espresso
15
 * @subpackage    core/services/address/formatters
16
 * @author        Brent Christensen
17
 * @since         4.8
18
 */
19 View Code Duplication
class InlineAddressFormatter extends AddressFormatter implements \EEI_Address_Formatter {
0 ignored issues
show
Duplication introduced by
This class 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...
20
21
	/**
22
	 * @param string $address
23
	 * @param string $address2
24
	 * @param string $city
25
	 * @param string $state
26
	 * @param string $zip
27
	 * @param string $country
28
	 * @param string $CNT_ISO
29
	 * @return string
30
	 */
31
	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) {
32
		$address_formats = apply_filters(
33
			'FHEE__EE_Inline_Address_Formatter__address_formats',
34
			array(
35
				'CA' => "{address}%{address2}%{city}%{state}%{country}%{zip}",
36
				'GB' => "{address}%{address2}%{city}%{state}%{zip}%{country}",
37
				'US' => "{address}%{address2}%{city}%{state}%{zip}%{country}",
38
				'ZZZ' => "{address}%{address2}%{city}%{state}%{zip}%{country}",
39
			)
40
		);
41
		// if the incoming country has a set format, use that, else use the default
42
		$formatted_address = isset( $address_formats[ $CNT_ISO ] ) ? $address_formats[ $CNT_ISO ]
43
			: $address_formats['ZZZ'];
44
		return $this->parse_formatted_address(
45
			$address,
46
			$address2,
47
			$city,
48
			$state,
49
			$zip,
50
			$country,
51
			$formatted_address,
52
			', '
53
		);
54
	}
55
56
}
57
// End of file InlineAddressFormatter.php
58
// Location: core/services/address/formatters/InlineAddressFormatter.php