generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new implementation based on tpetry/php-mysql-explain
- Loading branch information
Showing
23 changed files
with
267 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
includes: | ||
- phpstan-baseline.neon | ||
|
||
parameters: | ||
level: max | ||
paths: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tpetry\LaravelMysqlExplain; | ||
|
||
use Illuminate\Database\ConnectionInterface; | ||
use Tpetry\PhpMysqlExplain\Queries\QueryInterface; | ||
|
||
class LaravelQuery implements QueryInterface | ||
{ | ||
/** | ||
* @param array<array-key,mixed> $parameters | ||
*/ | ||
public function __construct( | ||
private ConnectionInterface $connection, | ||
private string $sql, | ||
private array $parameters, | ||
) {} | ||
|
||
public function execute(string $sql, bool $useParams): array | ||
{ | ||
$rows = match ($useParams) { | ||
true => $this->connection->select($sql, $this->parameters), | ||
false => $this->connection->select($sql), | ||
}; | ||
|
||
// Laravel creates array<object> instead of array<arrays> as requested by interface. | ||
$rows = array_map(fn ($row) => (array) $row, $rows); | ||
|
||
return $rows; | ||
} | ||
|
||
public function getParameters(): array | ||
{ | ||
// Transform special values like DateTimeInterface and bool to their string value. | ||
return $this->connection->prepareBindings($this->parameters); | ||
} | ||
|
||
public function getSql(): string | ||
{ | ||
return $this->sql; | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return 'laravel@'.MysqlExplain::$VERSION; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.