summaryrefslogtreecommitdiffstats
path: root/src/Controller/CheckResponse.php
diff options
context:
space:
mode:
authorArnold Daniels <arnold@jasny.net>2016-11-18 18:28:24 +0100
committerArnold Daniels <arnold@jasny.net>2016-11-18 18:28:24 +0100
commit43c6d835943b322c036e9ee47800d694cb6bb5de (patch)
treef56809890b4e65c2f4790fbd8be9593a3538a72c /src/Controller/CheckResponse.php
parent934b380f473b4e85e807f07d6bf516f4e227e112 (diff)
downloadcontroller-43c6d835943b322c036e9ee47800d694cb6bb5de.zip
controller-43c6d835943b322c036e9ee47800d694cb6bb5de.tar.gz
controller-43c6d835943b322c036e9ee47800d694cb6bb5de.tar.bz2
Refactored CheckRequest and CheckResponse traits
WIP Controller\Output Restructuring the tests (one test per trait)
Diffstat (limited to 'src/Controller/CheckResponse.php')
-rw-r--r--src/Controller/CheckResponse.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/Controller/CheckResponse.php b/src/Controller/CheckResponse.php
index 7c02d46..7509778 100644
--- a/src/Controller/CheckResponse.php
+++ b/src/Controller/CheckResponse.php
@@ -18,6 +18,17 @@ trait CheckResponse
/**
+ * Check if response is a 1xx informational
+ *
+ * @return boolean
+ */
+ public function isInformational()
+ {
+ $code = $this->getResponse()->getStatusCode() ?: 200;
+ return $code >= 100 && $code < 200;
+ }
+
+ /**
* Check if response is 2xx succesful, or empty
*
* @return boolean
@@ -25,8 +36,7 @@ trait CheckResponse
public function isSuccessful()
{
$code = $this->getResponse()->getStatusCode() ?: 200;
-
- return !$code || ($code >= 200 && $code < 300);
+ return $code >= 200 && $code < 300;
}
/**
@@ -37,7 +47,6 @@ trait CheckResponse
public function isRedirection()
{
$code = $this->getResponse()->getStatusCode() ?: 200;
-
return $code >= 300 && $code < 400;
}
@@ -49,7 +58,6 @@ trait CheckResponse
public function isClientError()
{
$code = $this->getResponse()->getStatusCode() ?: 200;
-
return $code >= 400 && $code < 500;
}
@@ -60,8 +68,9 @@ trait CheckResponse
*/
public function isServerError()
{
- return $this->getResponse()->getStatusCode() ?: 200 >= 500;
- }
+ $code = $this->getResponse()->getStatusCode() ?: 200;
+ return $code >= 500 && $code < 600;
+ }
/**
* Check if response is 4xx or 5xx error
@@ -71,5 +80,5 @@ trait CheckResponse
public function isError()
{
return $this->isClientError() || $this->isServerError();
- }
+ }
}