Skip to content

Commit

Permalink
Add support for DateTimeInterface objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mnabialek committed May 21, 2020
1 parent dc591ea commit 5a04465
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [2.2.6] - 2020-05-21
### Changed
- Add support for DateTimeImmutable objects

## [2.2.5] - 2020-03-22
### Changed
- Add support for Laravel 7
Expand Down
4 changes: 2 additions & 2 deletions src/Objects/Concerns/ReplacesBindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mnabialek\LaravelSqlLogger\Objects\Concerns;

use DateTime;
use DateTimeInterface;

trait ReplacesBindings
{
Expand Down Expand Up @@ -72,7 +72,7 @@ protected function getNamedParameterRegex($name)
protected function formatBindings($bindings)
{
foreach ($bindings as $key => $binding) {
if ($binding instanceof DateTime) {
if ($binding instanceof DateTimeInterface) {
$bindings[$key] = $binding->format('Y-m-d H:i:s');
} elseif (is_string($binding)) {
$bindings[$key] = str_replace("'", "\\'", $binding);
Expand Down

0 comments on commit 5a04465

Please sign in to comment.