DatabaseTransactions::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\CommandMiddleware;
4
5
use DB;
6
use League\Tactician\Middleware;
7
8
/**
9
 * Class DatabaseTransactions
10
 * Run everything with a DB transaction
11
 * @package Hechoenlaravel\JarvisFoundation\CommandMiddleware
12
 */
13
class DatabaseTransactions implements Middleware
14
{
15
16
    /**
17
     * @param object $command
18
     * @param callable $next
19
     * @return null
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
}