Merge pull request #2802 from PHPOffice/Performance-Experimental-Changes

Simplify validation of columnId/rowId values when creating a CellAddress object
This commit is contained in:
Mark Baker 2022-05-03 13:30:56 +02:00 committed by GitHub
commit 48b5d83ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 11 deletions

View File

@ -705,8 +705,8 @@ class Functions
public static function trimSheetFromCellReference(string $coordinate): string public static function trimSheetFromCellReference(string $coordinate): string
{ {
while (strpos($coordinate, '!') !== false) { if (strpos($coordinate, '!') !== false) {
$coordinate = substr($coordinate, strpos($coordinate, '!') + 1); $coordinate = substr($coordinate, strrpos($coordinate, '!') + 1);
} }
return $coordinate; return $coordinate;

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