Code Duplication    Length = 13-13 lines in 2 locations

src/Actions/ServerError.php 1 location

@@ 7-19 (lines=13) @@
4
5
use Mcustiel\PowerRoute\Common\TransactionData;
6
7
class ServerError implements ActionInterface
8
{
9
    public function execute(TransactionData $transactionData, $argument = null)
10
    {
11
        $argument = (int) $argument;
12
        if ($argument < 500 || $argument >= 600) {
13
            $argument = 500;
14
        }
15
        $transactionData->setResponse(
16
            $transactionData->getResponse()->withStatus($argument)
17
        );
18
    }
19
}
20

src/Actions/StatusCode.php 1 location

@@ 7-19 (lines=13) @@
4
5
use Mcustiel\PowerRoute\Common\TransactionData;
6
7
class StatusCode implements ActionInterface
8
{
9
    public function execute(TransactionData $transactionData, $argument = null)
10
    {
11
        $argument = (int) $argument ?: 200;
12
        if ($argument < 100 || $argument >= 600) {
13
            throw new \RuntimeException('Invalid status code: ' . $argument);
14
        }
15
        $transactionData->setResponse(
16
            $transactionData->getResponse()->withStatus($argument)
17
        );
18
    }
19
}
20