-1, 'vat' => 'B', 'name' => '', 'city' => '', 'postal' => '', 'address' => '', 'body' => '', ]; if (empty($otherVAT) || empty($ownVAT)) { return $result; } $request = new HttpRequest( new HttpUri( 'https://evatr.bff-online.de/evatrRPC?UstId_1=' . $ownVAT . '&UstId_2=' . $otherVAT ) ); $request->setMethod(RequestMethod::GET); $matches = []; try { $body = Rest::request($request)->getBody(); $result['body'] = $body; \preg_match('/ErrorCode.*?(\d+)/s', $body, $matches); switch ((int) ($matches[1] ?? 1)) { case 200: $result['vat'] = 'A'; break; default: $result['vat'] = 'B'; } $result['status'] = 0; } catch (\Throwable $_) { return $result; } return $result; } /** * {@inheritdoc} */ public static function validateQualified( string $otherVAT, string $ownVAT, string $otherName, string $otherCity, string $otherPostal, string $otherStreet ) : array { $result = [ 'status' => -1, 'vat' => 'B', 'name' => 'C', 'city' => 'C', 'postal' => 'C', 'address' => 'C', 'body' => '', ]; if (empty($otherVAT) || empty($ownVAT)) { return $result; } $request = new HttpRequest(new HttpUri( 'https://evatr.bff-online.de/evatrRPC?UstId_1=' . $ownVAT . '&UstId_2=' . $otherVAT . '&Firmenname=' . \urlencode($otherName) . '&Ort=' . \urlencode($otherCity) . '&PLZ=' . \urlencode($otherPostal) . '&Strasse=' . \urlencode($otherStreet) ) ); $request->setMethod(RequestMethod::GET); try { $body = Rest::request($request)->getBody(); $result['body'] = $body; $matches = []; \preg_match('/ErrorCode.*?(\d+)/s', $body, $matches); switch ((int) ($matches[1] ?? 1)) { case 200: $result['vat'] = 'A'; break; default: $result['vat'] = 'B'; } $matches = []; \preg_match('/Erg_PLZ.*?(A|B|C|D)/s', $body, $matches); $result['postal'] = $matches[1] ?? 'B'; $matches = []; \preg_match('/Erg_Ort.*?(A|B|C|D)/s', $body, $matches); $result['city'] = $matches[1] ?? 'B'; $matches = []; \preg_match('/Erg_Str.*?(A|B|C|D)/s', $body, $matches); $result['address'] = $matches[1] ?? 'B'; $matches = []; \preg_match('/Erg_Name.*?(A|B|C|D)/s', $body, $matches); $result['name'] = $matches[1] ?? 'B'; $result['status'] = 0; } catch (\Throwable $_) { return $result; } return $result; } }