The expression $wsdl of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
Loading history...
44
1
$this->wsdl = $wsdl;
45
1
}
46
2
}
47
48
/**
49
* Check VAT
50
*
51
* @param string $countryCode Country code
52
* @param string $vatNumber VAT number
53
*
54
* @return Response\CheckVatResponse
55
* @throws ViesException
56
*/
57
2
public function checkVat($countryCode, $vatNumber)
58
{
59
try {
60
2
return $this->getSoapClient()->checkVat(
61
array(
62
'countryCode' => $countryCode,
63
'vatNumber' => $vatNumber
64
)
65
);
66
2
} catch (SoapFault $e) {
67
2
throw new ViesException('Error communicating with VIES service', 0, $e);
68
}
69
}
70
71
/**
72
* Get SOAP client
73
*
74
* @return \SoapClient
75
*/
76
2
private function getSoapClient()
77
{
78
2
if (null === $this->soapClient) {
79
2
$this->soapClient = new \SoapClient(
80
2
$this->wsdl,
81
array(
82
2
'classmap' => $this->classmap,
83
2
'user_agent' => 'Mozilla', // the request fails unless a (dummy) user agent is specified
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: