Skip to content

Commit

Permalink
simplify check for error message
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaschen committed Jun 27, 2024
1 parent 84a6539 commit c4aa2c7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Response/CsvResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ public function __construct(protected Parser $parser, protected string $response
public function isError(): bool
{
foreach ($this->data as $data) {
if ($data[0] === 'MESSAGE' && $data[1] === 'E') {
$this->errorCode = $data[2];
$this->errorMessage = $data[3];
if (!$this->isErrorLine($data)) {
continue;
}

if (isset($data[4])) {
$this->errorLine = (int)$data[4];
}
$this->errorCode = $data[2];
$this->errorMessage = $data[3];

return true;
if (isset($data[4])) {
$this->errorLine = (int)$data[4];
}

return true;
}

return false;
Expand Down Expand Up @@ -155,4 +157,9 @@ private function convertEncodingFromCollmex(array $data): array

return $filter->filterArray($data);
}

private function isErrorLine(array $lineData): bool
{
return $lineData[0] === 'MESSAGE' && $lineData[1] === 'E';
}
}

0 comments on commit c4aa2c7

Please sign in to comment.