setMethod(RequestMethod::GET); $matches = []; try { $body = Rest::request($request)->getBody(); \preg_match('/ErrorCode.*?(\d+)/s', $body, $matches); if ((int) ($matches[1] ?? 1) === 200) { return 0; } } catch (\Throwable $t) { return -1; } return (int) ($matches[1] ?? 1); } /** * {@inheritdoc} */ public static function validateQualified( string $ownVAT, string $otherVAT, string $otherName, string $otherCity, string $otherPostal, string $otherStreet ) : array { $result = [ 'status' => -1, 'name' => false, 'city' => false, 'postal' => false, 'street' => false, 'response' => '', ]; if (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['response'] = $body; $matches = []; \preg_match('/ErrorCode.*?(\d+)/s', $body, $matches); if ((int) ($matches[1] ?? 1) === 200) { $result['status'] = 0; } $matches = []; \preg_match('/Erg_PLZ.*?(A|B|C|D)/s', $body, $matches); if (($matches[1] ?? 'B') === 'A' || ($matches[1] ?? 'B') === 'D') { $result['postal'] = true; } $matches = []; \preg_match('/Erg_Ort.*?(A|B|C|D)/s', $body, $matches); if (($matches[1] ?? 'B') === 'A' || ($matches[1] ?? 'B') === 'D') { $result['city'] = true; } $matches = []; \preg_match('/Erg_Str.*?(A|B|C|D)/s', $body, $matches); if (($matches[1] ?? 'B') === 'A' || ($matches[1] ?? 'B') === 'D') { $result['street'] = true; } $matches = []; \preg_match('/Erg_Name.*?(A|B|C|D)/s', $body, $matches); if (($matches[1] ?? 'B') === 'A' || ($matches[1] ?? 'B') === 'D') { $result['street'] = true; } } catch (\Throwable $t) { return []; } return $result; } }