DatabaseTransactions::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Joselfonseca\LaravelTactician\Middleware;
4
5
use DB;
6
use League\Tactician\Middleware;
7
8
/**
9
 * Run the command in a database transaction.
10
 * @package Joselfonseca\LaravelTactician\Middleware
11
 */
12
class DatabaseTransactions implements Middleware
13
{
14
15
    /**
16
     * @param object $command
17
     * @param callable $next
18
     * @return null
19
     * @codeCoverageIgnore
20
     */
21
    public function execute($command, callable $next)
22
    {
23
        $pipeline = null;
24
        DB::transaction(function () use ($next, $command, &$pipeline) {
25
            $pipeline = $next($command);
26
        });
27
        return $pipeline;
28
    }
29
}
30