Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
TransactionMiddleware | n/a |
0 / 0 |
n/a |
0 / 0 |
2 | n/a |
0 / 0 |
|||
__invoke | n/a |
0 / 0 |
n/a |
0 / 0 |
2 |
1 | <?php |
2 | |
3 | namespace BO\Zmsapi\Helper; |
4 | |
5 | use BO\Zmsdb\Connection\Select; |
6 | use Psr\Http\Message\ServerRequestInterface; |
7 | use Psr\Http\Server\RequestHandlerInterface; |
8 | |
9 | class TransactionMiddleware |
10 | { |
11 | /** |
12 | * @codeCoverageIgnore |
13 | * |
14 | */ |
15 | public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $next) |
16 | { |
17 | Select::setTransaction(); |
18 | try { |
19 | $response = $next->handle($request); |
20 | } catch (\Exception $exception) { |
21 | Select::writeRollback(); |
22 | throw $exception; |
23 | } |
24 | Select::writeCommit(); |
25 | |
26 | return $response; |
27 | } |
28 | } |