コード例 #1
0
ファイル: HttpStatusTest.php プロジェクト: gabrielbull/router
 public function testStringOutput()
 {
     // Set our manual test data
     $code = 404;
     $expected_string = '404 Not Found';
     // Create and echo our status
     $http_status = new HttpStatus($code);
     echo $http_status;
     $this->expectOutputString($expected_string);
     $this->assertSame($expected_string, $http_status->getFormattedString());
 }
コード例 #2
0
 /**
  * Get (or set) the HTTP response code
  *
  * Simply calling this method without any arguments returns the current response code.
  * Calling with an integer argument, however, attempts to set the response code to what
  * was provided by the argument.
  *
  * @param int $code The HTTP status code to send
  * @return int|AbstractResponse
  */
 public function code($code = null)
 {
     if (null !== $code) {
         // Require that the response be unlocked before changing it
         $this->requireUnlocked();
         $this->status = new HttpStatus($code);
         return $this;
     }
     return $this->status->getCode();
 }