Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
rename function (#11)
Browse files Browse the repository at this point in the history
* rename function

* update readme
  • Loading branch information
prisis authored Jun 22, 2016
1 parent d3610c6 commit d7e86ed
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ All Notable changes to `http-status` will be documented in this file
## NEXT - 2016-06-22

### Added
- HttpStatus::getReasonName | returns the status name.
- HttpStatus::getReasonMessage | returns the status message.

### Deprecated
- Nothing

### Fixed
- HttpStatus::getReasonPhrase | return now the status text for a error.
- Nothing

### Removed
- Nothing
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ $ composer require narrowspark/http-status

use Narrowspark\HttpStatus\HttpStatus;

// get status text from code
echo HttpStatus::getReasonPhrase(301); // This and all future requests should be directed to the given URI.
// get status message from code
echo HttpStatus::getReasonMessage(301); // This and all future requests should be directed to the given URI.

// get status name from code
echo HttpStatus::getReasonName(301); // Moved Permanently
echo HttpStatus::getReasonPhrase(301); // Moved Permanently

try {
HttpStatus::getReasonException(301):
Expand Down
8 changes: 4 additions & 4 deletions src/HttpStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,16 @@ private function __construct()
}

/**
* Get the text for a given status code.
* Get the message for a given status code.
*
* @param int $code http status code
*
* @throws InvalidArgumentException If the requested $code is not valid
* @throws OutOfBoundsException If the requested $code is not found
*
* @return string Returns text for the given status code
* @return string Returns message for the given status code
*/
public static function getReasonPhrase($code)
public static function getReasonMessage($code)
{
$code = static::filterStatusCode($code);

Expand All @@ -278,7 +278,7 @@ public static function getReasonPhrase($code)
*
* @return string Returns name for the given status code
*/
public static function getReasonName($code)
public static function getReasonPhrase($code)
{
$code = static::filterStatusCode($code);

Expand Down
28 changes: 14 additions & 14 deletions tests/HttpStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,24 @@ class HttpStatusTest extends \PHPUnit_Framework_TestCase
511 => Exception\NetworkAuthenticationRequiredException::class,
];

public function testGetReasonName()
public function testGetReasonPhrase()
{
foreach ($this->errorNames as $code => $text) {
$this->assertSame(
$text,
HttpStatus::getReasonName($code),
'Expected HttpStatus::getReasonName(' . $code . ') to return ' . $text
HttpStatus::getReasonPhrase($code),
'Expected HttpStatus::getReasonPhrase(' . $code . ') to return ' . $text
);
}
}

public function testGetReasonPhrase()
public function testGetReasonMessage()
{
foreach ($this->errorPhrases as $code => $text) {
$this->assertSame(
$text,
HttpStatus::getReasonPhrase($code),
'Expected HttpStatus::getReasonName(' . $code . ') to return ' . $text
HttpStatus::getReasonMessage($code),
'Expected HttpStatus::getReasonPhrase(' . $code . ') to return ' . $text
);
}
}
Expand All @@ -206,36 +206,36 @@ public function testGetReasonPhrase()
* @expectedException InvalidArgumentException
* @expectedExceptionMessage The submitted code must be a positive integer between 100 and 599.
*/
public function testGetReasonNameToThrowInvalidArgumentException()
public function testGetReasonPhraseToThrowInvalidArgumentException()
{
HttpStatus::getReasonName(700);
HttpStatus::getReasonPhrase(700);
}

/**
* @expectedException OutOfBoundsException
* @expectedExceptionMessage Unknown http status code: `509`.
*/
public function testGetReasonNameToThrowOutOfBoundsException()
public function testGetReasonPhraseToThrowOutOfBoundsException()
{
HttpStatus::getReasonName(509);
HttpStatus::getReasonPhrase(509);
}

/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage The submitted code must be a positive integer between 100 and 599.
*/
public function testGetReasonPhraseToThrowInvalidArgumentException()
public function testGetReasonMessageToThrowInvalidArgumentException()
{
HttpStatus::getReasonPhrase(700);
HttpStatus::getReasonMessage(700);
}

/**
* @expectedException OutOfBoundsException
* @expectedExceptionMessage Unknown http status code: `509`.
*/
public function testGetReasonPhraseToThrowOutOfBoundsException()
public function testGetReasonMessageToThrowOutOfBoundsException()
{
HttpStatus::getReasonPhrase(509);
HttpStatus::getReasonMessage(509);
}

public function testGetReasonException()
Expand Down

0 comments on commit d7e86ed

Please sign in to comment.