Simplify validation of columnId/rowId values when creating a CellAddress object

This commit is contained in:
MarkBaker 2022-05-03 12:13:10 +02:00
parent fde77306ff
commit b4fc92ec7e
1 changed files with 3 additions and 9 deletions

View File

@ -47,16 +47,10 @@ class CellAddress
*/ */
private static function validateColumnAndRow($columnId, $rowId): void private static function validateColumnAndRow($columnId, $rowId): void
{ {
$array = [$columnId, $rowId]; if (!is_numeric($columnId) || $columnId <= 0 || !is_numeric($rowId) || $rowId <= 0) {
array_walk(
$array,
function ($value): void {
if (!is_numeric($value) || $value <= 0) {
throw new Exception('Row and Column Ids must be positive integer values'); throw new Exception('Row and Column Ids must be positive integer values');
} }
} }
);
}
/** /**
* @param mixed $columnId * @param mixed $columnId