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

AddressFormatter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse_formatted_address() 0 22 1
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 AddressFormatter
12
 * Base class for address formatters
13
 *
14
 * @package Event Espresso
15
 * @author  Brent Christensen
16
 * @since   4.8
17
 */
18
class AddressFormatter {
19
20
	/**
21
	 * @param string $address
22
	 * @param string $address2
23
	 * @param string $city
24
	 * @param string $state
25
	 * @param string $zip
26
	 * @param string $country
27
	 * @param string $formatted_address
28
	 * @param string $sub
29
	 * @return mixed
30
	 */
31
	protected function parse_formatted_address(
32
		$address,
33
		$address2,
34
		$city,
35
		$state,
36
		$zip,
37
		$country,
38
		$formatted_address,
39
		$sub
40
	) {
41
		// swap address part placeholders for the real text
42
		$formatted_address = str_replace(
43
		// find
44
			array( '{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}' ),
45
			// replace
46
			array( $address, $address2, $city, $state, $zip, $country ),
47
			// string
48
			$formatted_address
49
		);
50
		// remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks
51
		return preg_replace( '/%+/', $sub, trim( $formatted_address, '%' ) );
52
	}
53
54
55
}
56
// End of file AddressFormatter.php
57
// Location: core/services/address/formatters/AddressFormatter.php