-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
Moved the error handling for SqlFileNotFoundException into its own private method, handleSqlNotFound, for improved readability and simplicity. This change does not alter the functionality but enhances code structure and maintainability.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,18 +48,23 @@ public function get(): QueryInterface | |
// For development | ||
// @codeCoverageIgnoreStart | ||
} catch (SqlFileNotFoundException $e) { | ||
try { | ||
$named = $e->sql; | ||
$instance = $this->injector->getInstance(RowInterface::class, $named); | ||
error_log(sprintf('Warning: #[Sql(\'%s\')] is not vald. Change to #[\\Ray\\Di\\Di\\Named(\'%s\')]', $named, $named)); | ||
|
||
return $instance; | ||
} catch (Unbound $unbound) { | ||
throw $e; | ||
} | ||
// @codeCoverageIgnoreEnd | ||
return $this->handleSqlNotFound($e); | ||
Check failure on line 51 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
|
||
} | ||
|
||
return new SqlQueryRow($this->pdo, $sql); | ||
} | ||
|
||
private function handleSqlNotFound($e) | ||
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / cs / Coding Standards
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / cs / Coding Standards
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / sa / PHPStan
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / sa / PHPStan
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / sa / PHPStan
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / sa / PHPStan
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / cs / Coding Standards
Check failure on line 57 in src/RowInterfaceProvider.php GitHub Actions / cs / Coding Standards
|
||
{ | ||
try { | ||
$named = $e->sql; | ||
Check failure on line 60 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
Check failure on line 60 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
Check failure on line 60 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
|
||
$instance = $this->injector->getInstance(RowInterface::class, $named); | ||
Check failure on line 61 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
|
||
error_log(sprintf('Warning: #[Sql(\'%s\')] is not vald. Change to #[\\Ray\\Di\\Di\\Named(\'%s\')]', $named, $named)); | ||
Check failure on line 62 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
Check failure on line 62 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
Check failure on line 62 in src/RowInterfaceProvider.php GitHub Actions / sa / Psalm
|
||
|
||
return $instance; | ||
} catch (Unbound $unbound) { | ||
throw $e; | ||
} | ||
// @codeCoverageIgnoreEnd | ||
} | ||
} |