Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 27, 2020
1 parent 04df2e1 commit 9565598
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 32 deletions.
40 changes: 14 additions & 26 deletions src/Illuminate/Database/Concerns/ManagesTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public function transaction(Closure $callback, $attempts = 1)
if ($this->transactions == 1) {
$this->getPdo()->commit();

if ($this->transactionsManager) {
$this->transactionsManager->commit($this->getName());
}
optional($this->transactionsManager)->commit($this->getName());
}

$this->transactions = max(0, $this->transactions - 1);
Expand Down Expand Up @@ -83,11 +81,9 @@ protected function handleTransactionException(Throwable $e, $currentAttempt, $ma
$this->transactions > 1) {
$this->transactions--;

if ($this->transactionsManager) {
$this->transactionsManager->rollback(
$this->getName(), $this->transactions
);
}
optional($this->transactionsManager)->rollback(
$this->getName(), $this->transactions
);

throw $e;
}
Expand Down Expand Up @@ -118,11 +114,9 @@ public function beginTransaction()

$this->transactions++;

if ($this->transactionsManager) {
$this->transactionsManager->begin(
$this->getName(), $this->transactions
);
}
optional($this->transactionsManager)->begin(
$this->getName(), $this->transactions
);

$this->fireConnectionEvent('beganTransaction');
}
Expand Down Expand Up @@ -194,9 +188,7 @@ public function commit()
if ($this->transactions == 1) {
$this->getPdo()->commit();

if ($this->transactionsManager) {
$this->transactionsManager->commit($this->getName());
}
optional($this->transactionsManager)->commit($this->getName());
}

$this->transactions = max(0, $this->transactions - 1);
Expand Down Expand Up @@ -262,11 +254,9 @@ public function rollBack($toLevel = null)

$this->transactions = $toLevel;

if ($this->transactionsManager) {
$this->transactionsManager->rollback(
$this->getName(), $this->transactions
);
}
optional($this->transactionsManager)->rollback(
$this->getName(), $this->transactions
);

$this->fireConnectionEvent('rollingBack');
}
Expand Down Expand Up @@ -303,11 +293,9 @@ protected function handleRollBackException(Throwable $e)
if ($this->causedByLostConnection($e)) {
$this->transactions = 0;

if ($this->transactionsManager) {
$this->transactionsManager->rollback(
$this->getName(), $this->transactions
);
}
optional($this->transactionsManager)->rollback(
$this->getName(), $this->transactions
);
}

throw $e;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ public function setTransactionManager($manager)
}

/**
* Unset the event transaction manager for this connection.
* Unset the transaction manager for this connection.
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/DatabaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function registerConnectionServices()
});

$this->app->singleton('db.transactions', function ($app) {
return new DatabaseTransactionsManager();
return new DatabaseTransactionsManager;
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Database/DatabaseTransactionsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class DatabaseTransactionsManager
{
/**
* All the recorded transactions.
* All of the recorded transactions.
*
* @var \Illuminate\Support\Collection
*/
Expand Down Expand Up @@ -46,7 +46,7 @@ public function rollback($connection, $level)
{
$this->transactions = $this->transactions->reject(function ($transaction) use ($connection, $level) {
return $transaction->connection == $connection &&
$transaction->level > $level;
$transaction->level > $level;
})->values();
}

Expand All @@ -72,8 +72,8 @@ public function commit($connection)
/**
* Register a transaction callback.
*
* @param callable $callback
* @return void.
* @param callable $callback
* @return void
*/
public function addCallback($callback)
{
Expand Down

0 comments on commit 9565598

Please sign in to comment.