Skip to content

Commit

Permalink
Add handling for null errorSuite in addErrorSuit method and set filen…
Browse files Browse the repository at this point in the history
…ame to null and create new Data object in Schema.php.
  • Loading branch information
Denis Smet committed Mar 10, 2024
1 parent 2d6ffef commit ef47403
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public function __construct(null|array|string $csvSchemaFilenameOrArray = null)
}
} elseif (\is_string($csvSchemaFilenameOrArray)) {
throw new \InvalidArgumentException("Invalid schema data: {$csvSchemaFilenameOrArray}");
} else {
$this->filename = null;
$this->data = new Data();
}

$this->columns = $this->prepareColumns();
Expand Down
4 changes: 4 additions & 0 deletions src/Validators/ErrorSuite.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public function addError(?Error $error): self

public function addErrorSuit(?self $errorSuite): self
{
if ($errorSuite === null) {
return $this;
}

$this->errors = \array_merge($this->getErrors(), $errorSuite->getErrors());

return $this;
Expand Down

0 comments on commit ef47403

Please sign in to comment.