Completed
Branch master (ed410a)
by Mariano
03:14
created

StatusCode::execute()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.2
cc 4
eloc 6
nc 4
nop 2
crap 4
1
<?php
2
namespace Mcustiel\PowerRoute\Actions;
3
4
use Mcustiel\PowerRoute\Common\TransactionData;
5
6
class StatusCode implements ActionInterface
7
{
8 4
    public function execute(TransactionData $transactionData, $argument = null)
9
    {
10 4
        $argument = (integer) $argument ?: 200;
11 4
        if ($argument < 100 || $argument >= 600) {
12 1
            throw new \RuntimeException('Invalid status code: ' . $argument);
13
        }
14 3
        return $transactionData->setResponse(
15 3
            $transactionData->getResponse()->withStatus($argument)
16 3
        );
17
    }
18
}
19