checkvat_number(); } private function checkvat_number(): self { $wsdl = "https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"; try { $client = new \SoapClient($wsdl); $params = [ 'countryCode' => $this->country_code, 'vatNumber' => $this->vat_number ]; $response = $client->checkVat($params); if ($response->valid) { $this->response = [ 'valid' => true, 'name' => $response->name, 'address' => $response->address ]; } else { $this->response = ['valid' => false]; } } catch (\SoapFault $e) { $this->response = ['valid' => false, 'error' => $e->getMessage()]; } return $this; } public function getResponse() { return $this->response; } public function isValid(): bool { return $this->response['valid']; } }