Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
2a3f088d
Commit
2a3f088d
authored
Jun 10, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #524 from cebe/response-api-getter
API consistency in Response class
parents
95bfd825
e5d8e4ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
Response.php
framework/yii/web/Response.php
+11
-11
No files found.
framework/yii/web/Response.php
View file @
2a3f088d
...
@@ -158,7 +158,7 @@ class Response extends \yii\base\Response
...
@@ -158,7 +158,7 @@ class Response extends \yii\base\Response
public
function
setStatusCode
(
$value
,
$text
=
null
)
public
function
setStatusCode
(
$value
,
$text
=
null
)
{
{
$this
->
_statusCode
=
(
int
)
$value
;
$this
->
_statusCode
=
(
int
)
$value
;
if
(
$this
->
i
sInvalid
())
{
if
(
$this
->
getI
sInvalid
())
{
throw
new
InvalidParamException
(
"The HTTP status code is invalid:
$value
"
);
throw
new
InvalidParamException
(
"The HTTP status code is invalid:
$value
"
);
}
}
if
(
$text
===
null
)
{
if
(
$text
===
null
)
{
...
@@ -565,7 +565,7 @@ class Response extends \yii\base\Response
...
@@ -565,7 +565,7 @@ class Response extends \yii\base\Response
/**
/**
* @return boolean whether this response has a valid [[statusCode]].
* @return boolean whether this response has a valid [[statusCode]].
*/
*/
public
function
i
sInvalid
()
public
function
getI
sInvalid
()
{
{
return
$this
->
getStatusCode
()
<
100
||
$this
->
getStatusCode
()
>=
600
;
return
$this
->
getStatusCode
()
<
100
||
$this
->
getStatusCode
()
>=
600
;
}
}
...
@@ -573,7 +573,7 @@ class Response extends \yii\base\Response
...
@@ -573,7 +573,7 @@ class Response extends \yii\base\Response
/**
/**
* @return boolean whether this response is informational
* @return boolean whether this response is informational
*/
*/
public
function
i
sInformational
()
public
function
getI
sInformational
()
{
{
return
$this
->
getStatusCode
()
>=
100
&&
$this
->
getStatusCode
()
<
200
;
return
$this
->
getStatusCode
()
>=
100
&&
$this
->
getStatusCode
()
<
200
;
}
}
...
@@ -581,7 +581,7 @@ class Response extends \yii\base\Response
...
@@ -581,7 +581,7 @@ class Response extends \yii\base\Response
/**
/**
* @return boolean whether this response is successful
* @return boolean whether this response is successful
*/
*/
public
function
i
sSuccessful
()
public
function
getI
sSuccessful
()
{
{
return
$this
->
getStatusCode
()
>=
200
&&
$this
->
getStatusCode
()
<
300
;
return
$this
->
getStatusCode
()
>=
200
&&
$this
->
getStatusCode
()
<
300
;
}
}
...
@@ -589,7 +589,7 @@ class Response extends \yii\base\Response
...
@@ -589,7 +589,7 @@ class Response extends \yii\base\Response
/**
/**
* @return boolean whether this response is a redirection
* @return boolean whether this response is a redirection
*/
*/
public
function
i
sRedirection
()
public
function
getI
sRedirection
()
{
{
return
$this
->
getStatusCode
()
>=
300
&&
$this
->
getStatusCode
()
<
400
;
return
$this
->
getStatusCode
()
>=
300
&&
$this
->
getStatusCode
()
<
400
;
}
}
...
@@ -597,7 +597,7 @@ class Response extends \yii\base\Response
...
@@ -597,7 +597,7 @@ class Response extends \yii\base\Response
/**
/**
* @return boolean whether this response indicates a client error
* @return boolean whether this response indicates a client error
*/
*/
public
function
i
sClientError
()
public
function
getI
sClientError
()
{
{
return
$this
->
getStatusCode
()
>=
400
&&
$this
->
getStatusCode
()
<
500
;
return
$this
->
getStatusCode
()
>=
400
&&
$this
->
getStatusCode
()
<
500
;
}
}
...
@@ -605,7 +605,7 @@ class Response extends \yii\base\Response
...
@@ -605,7 +605,7 @@ class Response extends \yii\base\Response
/**
/**
* @return boolean whether this response indicates a server error
* @return boolean whether this response indicates a server error
*/
*/
public
function
i
sServerError
()
public
function
getI
sServerError
()
{
{
return
$this
->
getStatusCode
()
>=
500
&&
$this
->
getStatusCode
()
<
600
;
return
$this
->
getStatusCode
()
>=
500
&&
$this
->
getStatusCode
()
<
600
;
}
}
...
@@ -613,7 +613,7 @@ class Response extends \yii\base\Response
...
@@ -613,7 +613,7 @@ class Response extends \yii\base\Response
/**
/**
* @return boolean whether this response is OK
* @return boolean whether this response is OK
*/
*/
public
function
i
sOk
()
public
function
getI
sOk
()
{
{
return
200
===
$this
->
getStatusCode
();
return
200
===
$this
->
getStatusCode
();
}
}
...
@@ -621,7 +621,7 @@ class Response extends \yii\base\Response
...
@@ -621,7 +621,7 @@ class Response extends \yii\base\Response
/**
/**
* @return boolean whether this response indicates the current request is forbidden
* @return boolean whether this response indicates the current request is forbidden
*/
*/
public
function
i
sForbidden
()
public
function
getI
sForbidden
()
{
{
return
403
===
$this
->
getStatusCode
();
return
403
===
$this
->
getStatusCode
();
}
}
...
@@ -629,7 +629,7 @@ class Response extends \yii\base\Response
...
@@ -629,7 +629,7 @@ class Response extends \yii\base\Response
/**
/**
* @return boolean whether this response indicates the currently requested resource is not found
* @return boolean whether this response indicates the currently requested resource is not found
*/
*/
public
function
i
sNotFound
()
public
function
getI
sNotFound
()
{
{
return
404
===
$this
->
getStatusCode
();
return
404
===
$this
->
getStatusCode
();
}
}
...
@@ -637,7 +637,7 @@ class Response extends \yii\base\Response
...
@@ -637,7 +637,7 @@ class Response extends \yii\base\Response
/**
/**
* @return boolean whether this response is empty
* @return boolean whether this response is empty
*/
*/
public
function
i
sEmpty
()
public
function
getI
sEmpty
()
{
{
return
in_array
(
$this
->
getStatusCode
(),
array
(
201
,
204
,
304
));
return
in_array
(
$this
->
getStatusCode
(),
array
(
201
,
204
,
304
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment