Skip to content

Commit

Permalink
#2648 Replaced duplicated code with variadic argument
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Mar 30, 2018
1 parent f98a9f3 commit bd9bdd1
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions lib/Doctrine/DBAL/Driver/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use Doctrine\DBAL\ParameterType;
use PDO;
use function func_get_args;

/**
* PDO implementation of the Connection interface.
Expand Down Expand Up @@ -97,36 +98,8 @@ public function prepare($prepareString, $driverOptions = [])
*/
public function query()
{
$args = func_get_args();
$argsCount = count($args);

try {
if ($argsCount == 4) {
$stmt = parent::query($args[0], $args[1], $args[2], $args[3]);

$this->trackLastInsertId();

return $stmt;
}

if ($argsCount == 3) {
$stmt = parent::query($args[0], $args[1], $args[2]);

$this->trackLastInsertId();

return $stmt;
}

if ($argsCount == 2) {
$stmt = parent::query($args[0], $args[1]);

$this->trackLastInsertId();

return $stmt;
}

$stmt = parent::query($args[0]);

$stmt = parent::query(...func_get_args());

$this->trackLastInsertId();

Expand Down

0 comments on commit bd9bdd1

Please sign in to comment.