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

StatusCode   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
wmc 4
lcom 0
cbo 2
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 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