From d7e86edcec8214f8f6bf5e9888ab11c097d66e65 Mon Sep 17 00:00:00 2001 From: Daniel Bannert Date: Wed, 22 Jun 2016 16:26:37 +0200 Subject: [PATCH] rename function (#11) * rename function * update readme --- CHANGELOG.md | 4 ++-- README.md | 6 +++--- src/HttpStatus.php | 8 ++++---- tests/HttpStatusTest.php | 28 ++++++++++++++-------------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af6f3e3..8b13b99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 308fb2e..d720b3b 100644 --- a/README.md +++ b/README.md @@ -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): diff --git a/src/HttpStatus.php b/src/HttpStatus.php index e8125ff..918f8c2 100644 --- a/src/HttpStatus.php +++ b/src/HttpStatus.php @@ -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); @@ -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); diff --git a/tests/HttpStatusTest.php b/tests/HttpStatusTest.php index 8ea0bd4..ebafd77 100644 --- a/tests/HttpStatusTest.php +++ b/tests/HttpStatusTest.php @@ -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 ); } } @@ -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()