Failed Conditions
Push — develop ( 0c4589...6de45b )
by Reüel
24:44 queued 13:15
created

src/AddressTransformer.php (2 issues)

Labels
Severity
1
<?php
2
/**
3
 * Address transformer
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2019 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\Adyen
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Adyen;
12
13
use Pronamic\WordPress\Pay\Address as Pay_Address;
14
15
/**
16
 * Address transformer
17
 *
18
 * @author  Remco Tolsma
19
 * @version 1.0.0
20
 * @since   1.0.0
21
 */
22
class AddressTransformer {
23
	/**
24
	 * Transform WordPress Pay address to Adyen address.
25
	 *
26
	 * @param Pay_Address $address WordPress Pay address to convert.
27
	 * @return Address|null
28
	 */
29
	public static function transform( Pay_Address $address ) {
30
		$country = $address->get_country();
0 ignored issues
show
The method get_country() does not exist on Pronamic\WordPress\Pay\Address. Did you maybe mean get_country_name()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
		/** @scrutinizer ignore-call */ 
31
  $country = $address->get_country();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
32
		if ( null === $country ) {
33
			return null;
34
		}
35
36
		$country_code = $country->get_code();
37
38
		if ( null === $country_code ) {
39
			return null;
40
		}
41
42
		$state_or_province = null;
43
44
		$region = $address->get_region();
45
46
		if ( null !== $region ) {
47
			$state_or_province = $region->get_code();
48
		}
49
50
		try {
51
			$address = new Address(
52
				$country_code,
53
				$address->get_street_name(),
54
				strval( $address->get_house_number() ),
55
				$address->get_postal_code(),
56
				$address->get_city(),
57
				$state_or_province
58
			);
59
		} catch ( InvalidArgumentException $exception ) {
0 ignored issues
show
The type Pronamic\WordPress\Pay\G...nvalidArgumentException was not found. Did you mean InvalidArgumentException? If so, make sure to prefix the type with \.
Loading history...
60
			return null;
61
		}
62
63
		return $address;
64
	}
65
}
66