Skip to content

Commit

Permalink
ignore invalid properties for configure
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Dec 27, 2023
1 parent 789938a commit e2dd2d0
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Csv/CsvAdapter.php
Original file line number Diff line number Diff line change
@@ -44,6 +44,9 @@ public function configure(...$opts): void
if (is_numeric($k)) {
throw new Exception("Invalid key");
}
if (!property_exists($this, $k)) {
continue;
}
$this->$k = $v;
}
}
6 changes: 6 additions & 0 deletions src/Xls/XlsAdapter.php
Original file line number Diff line number Diff line change
@@ -16,6 +16,12 @@ abstract class XlsAdapter implements SpreadInterface
public function configure(...$opts): void
{
foreach ($opts as $k => $v) {
if (is_numeric($k)) {
throw new Exception("Invalid key");

Check failure on line 20 in src/Xls/XlsAdapter.php

GitHub Actions / build-test

Instantiated class LeKoala\SpreadCompat\Xls\Exception not found.

Check failure on line 20 in src/Xls/XlsAdapter.php

GitHub Actions / build-test

Throwing object of an unknown class LeKoala\SpreadCompat\Xls\Exception.
}
if (!property_exists($this, $k)) {
continue;
}
$this->$k = $v;
}
}
7 changes: 7 additions & 0 deletions src/Xlsx/XlsxAdapter.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

namespace LeKoala\SpreadCompat\Xlsx;

use Exception;
use LeKoala\SpreadCompat\SpreadInterface;

abstract class XlsxAdapter implements SpreadInterface
@@ -16,6 +17,12 @@ abstract class XlsxAdapter implements SpreadInterface
public function configure(...$opts): void
{
foreach ($opts as $k => $v) {
if (is_numeric($k)) {
throw new Exception("Invalid key");
}
if (!property_exists($this, $k)) {
continue;
}
$this->$k = $v;
}
}

0 comments on commit e2dd2d0

Please sign in to comment.