Completed
Push — master ( a40390...c25130 )
by
11s
created

StoragePersistMiddleware   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 2
1
<?php
2
3
/*
4
 * This file is part of the LineMob package.
5
 *
6
 * (c) Ishmael Doss <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LineMob\Core\Mocky\Doctrine;
13
14
use League\Tactician\Middleware;
15
use LineMob\Core\Command\AbstractCommand;
16
17
/**
18
 * @author Ishmael Doss <[email protected]>
19
 */
20
class StoragePersistMiddleware implements Middleware
21
{
22
    /**
23
     * @param AbstractCommand $command
24
     *
25
     * {@inheritdoc}
26
     */
27
    public function execute($command, callable $next)
28
    {
29
        if (!$command->storage) {
30
            throw new \LogicException("Require storage before using this StoragePersistMiddleware!");
31
        }
32
33
        Manager::persist($command->storage);
34
        Manager::flush();
35
36
        return $next($command);
37
    }
38
}
39