| @@ 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 | ||
| @@ 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 | ||