getStatusCode() public method

Get the status code.
public getStatusCode ( ) : integer
return integer
Esempio n. 1
0
 public function testResponse()
 {
     $serverResponse = new ServerResponse('Hola user!');
     $this->assertEquals('Hola user!', $serverResponse->getContent());
     $this->assertEquals(200, $serverResponse->getStatusCode());
     $this->assertEquals('text/html', $serverResponse->getContentType());
     $serverResponse->setContent('Hola user again!');
     $this->assertEquals('Hola user again!', $serverResponse->getContent());
     $serverResponse->setStatusCode(204);
     $this->assertEquals(204, $serverResponse->getStatusCode());
     $serverResponse->setContentType('text/xml');
     $this->assertEquals('text/xml', $serverResponse->getContentType());
 }
Esempio n. 2
0
 private function buildFinalResponse(ServerResponse $response)
 {
     $finalResponse = ['content' => $response->getContent(), 'headers' => ['Content-Type' => $response->getContentType()], 'status_code' => $response->getStatusCode()];
     if ($finalResponse['status_code'] >= 400) {
         $model = $this->getErrorModel($finalResponse['status_code'], $finalResponse['content']);
         $finalResponse['content'] = $this->twig->render($this->errorDocument, $model);
     }
     return $finalResponse;
 }