Completed
Push — master ( 3a2c7f...b1be96 )
by Mariano
04:57
created

Psr7MiddlewareAction   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 1
c 3
b 0
f 1
lcom 0
cbo 1
dl 0
loc 21
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 12 1
1
<?php
2
namespace Mcustiel\PowerRoute\Actions;
3
4
use Mcustiel\PowerRoute\Common\TransactionData;
5
6
class Psr7MiddlewareAction implements ActionInterface
7
{
8
    /**
9
     * Executes a PSR-7 middleware.
10
     *
11
     * @param \Mcustiel\PowerRoute\Common\TransactionData                $transactionData
12
     * @param \Mcustiel\PowerRoute\Common\Conditions\ClassArgumentObject $argument
13
     */
14 3
    public function execute(TransactionData $transactionData, $argument = null)
15
    {
16 3
        $middleware = $argument->getInstance();
0 ignored issues
show
Bug introduced by
It seems like $argument is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
17
18 3
        $transactionData->setResponse(
19 3
            $middleware(
20 3
                $transactionData->getRequest(),
21 3
                $transactionData->getResponse(),
22 3
                $argument->getArgument()
23 3
            )
24 3
        );
25 3
    }
26
}
27