Psr7MiddlewareAction::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 12
cts 12
cp 1
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Mcustiel\PowerRoute\Actions;
4
5
use Mcustiel\PowerRoute\Common\TransactionData;
6
use Mcustiel\PowerRoute\Common\Conditions\ClassArgumentObject;
7
8
class Psr7MiddlewareAction implements ActionInterface
9
{
10
    /**
11
     * Executes a PSR-7 middleware.
12
     *
13
     * @param \Mcustiel\PowerRoute\Common\TransactionData                $transactionData
14
     * @param \Mcustiel\PowerRoute\Common\Conditions\ClassArgumentObject $argument
15
     */
16 3
    public function execute(TransactionData $transactionData, $argument = null)
17
    {
18 3
        if ($argument instanceof ClassArgumentObject) {
19 3
            $middleware = $argument->getInstance();
20
21 3
            $transactionData->setResponse(
22 3
                $middleware(
23 3
                    $transactionData->getRequest(),
24 3
                    $transactionData->getResponse(),
25 3
                    $argument->getArgument()
26 3
                )
27 3
            );
28 3
        }
29 3
    }
30
}
31