1 | <?php |
||
19 | trait HttpStatusTrait |
||
20 | { |
||
21 | /** |
||
22 | * Get status code. |
||
23 | * |
||
24 | * @return int |
||
25 | */ |
||
26 | public function getStatusCode() |
||
27 | { |
||
28 | if (property_exists($this, 'statusCode')) { |
||
29 | return $this->{'statusCode'}; |
||
30 | } |
||
31 | |||
32 | return null; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Set status code. |
||
37 | * |
||
38 | * @param int $statusCode |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function setStatusCode($statusCode) |
||
55 | |||
56 | /** |
||
57 | * Get status text. |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | public function getStatusText() |
||
62 | { |
||
63 | if (property_exists($this, 'statusText')) { |
||
64 | return $this->{'statusText'}; |
||
65 | } |
||
66 | |||
67 | return null; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Check if current response is valid status code. |
||
72 | * |
||
73 | * @return bool |
||
74 | */ |
||
75 | public function isValid() |
||
79 | |||
80 | /** |
||
81 | * Check if current response is informational. |
||
82 | * |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function isInformational() |
||
89 | |||
90 | /** |
||
91 | * Check if current response is successful. |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | public function isSuccessful() |
||
99 | |||
100 | /** |
||
101 | * Check if current response is redirection. |
||
102 | * |
||
103 | * @return bool |
||
104 | */ |
||
105 | public function isRedirection() |
||
109 | |||
110 | /** |
||
111 | * Check if current response is client error. |
||
112 | * |
||
113 | * @return bool |
||
114 | */ |
||
115 | public function isClientError() |
||
119 | |||
120 | /** |
||
121 | * Check if current response is server error. |
||
122 | * |
||
123 | * @return bool |
||
124 | */ |
||
125 | public function isServerError() |
||
129 | |||
130 | /** |
||
131 | * Check if current response is ok. |
||
132 | * |
||
133 | * @return bool |
||
134 | */ |
||
135 | public function isOk() |
||
139 | |||
140 | /** |
||
141 | * Check if current response is forbidden. |
||
142 | * |
||
143 | * @return bool |
||
144 | */ |
||
145 | public function isForbidden() |
||
149 | |||
150 | /** |
||
151 | * Check if current response is not found. |
||
152 | * |
||
153 | * @return bool |
||
154 | */ |
||
155 | public function isNotFound() |
||
159 | |||
160 | /** |
||
161 | * Check if current response is empty. |
||
162 | * |
||
163 | * @return bool |
||
164 | */ |
||
165 | public function isEmpty() |
||
169 | |||
170 | /** |
||
171 | * Check if response is not modified. |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function isNotModified() |
||
179 | } |
||
180 |