|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Bubu\Http\Reponse; |
| 4 | + |
| 5 | +trait DefaultHttpReponse |
| 6 | +{ |
| 7 | + |
| 8 | + // 200 |
| 9 | + |
| 10 | + public function reponse200(): self |
| 11 | + { |
| 12 | + $this->httpCode = 200; |
| 13 | + $this->message = 'OK'; |
| 14 | + return $this; |
| 15 | + } |
| 16 | + |
| 17 | + public function reponse201(): self |
| 18 | + { |
| 19 | + $this->httpCode = 201; |
| 20 | + $this->message = 'CREATED'; |
| 21 | + return $this; |
| 22 | + } |
| 23 | + |
| 24 | + public function reponse202(): self |
| 25 | + { |
| 26 | + $this->httpCode = 202; |
| 27 | + $this->message = 'ACCEPTED'; |
| 28 | + return $this; |
| 29 | + } |
| 30 | + |
| 31 | + public function reponse206(): self |
| 32 | + { |
| 33 | + $this->httpCode = 206; |
| 34 | + $this->message = 'Partial Content'; |
| 35 | + return $this; |
| 36 | + } |
| 37 | + |
| 38 | + |
| 39 | + // 300 |
| 40 | + |
| 41 | + public function reponse301(): self |
| 42 | + { |
| 43 | + $this->httpCode = 301; |
| 44 | + $this->message = 'Moved Permanently'; |
| 45 | + return $this; |
| 46 | + } |
| 47 | + |
| 48 | + public function reponse302(): self |
| 49 | + { |
| 50 | + $this->httpCode = 302; |
| 51 | + $this->message = 'Found'; |
| 52 | + return $this; |
| 53 | + } |
| 54 | + |
| 55 | + public function reponse304(): self |
| 56 | + { |
| 57 | + $this->httpCode = 304; |
| 58 | + $this->message = 'Not Modified'; |
| 59 | + return $this; |
| 60 | + } |
| 61 | + |
| 62 | + |
| 63 | + // 400 |
| 64 | + |
| 65 | + public function reponse400(): self |
| 66 | + { |
| 67 | + $this->httpCode = 400; |
| 68 | + $this->message = 'Bad Request'; |
| 69 | + return $this; |
| 70 | + } |
| 71 | + |
| 72 | + public function reponse401(): self |
| 73 | + { |
| 74 | + $this->httpCode = 401; |
| 75 | + $this->message = 'Unauthorized'; |
| 76 | + return $this; |
| 77 | + } |
| 78 | + |
| 79 | + public function reponse402(): self |
| 80 | + { |
| 81 | + $this->httpCode = 402; |
| 82 | + $this->message = 'Payement Required'; |
| 83 | + return $this; |
| 84 | + } |
| 85 | + |
| 86 | + public function reponse403(): self |
| 87 | + { |
| 88 | + $this->httpCode = 403; |
| 89 | + $this->message = 'Forbidden'; |
| 90 | + return $this; |
| 91 | + } |
| 92 | + |
| 93 | + public function reponse404(): self |
| 94 | + { |
| 95 | + $this->httpCode = 404; |
| 96 | + $this->message = 'OK'; |
| 97 | + return $this; |
| 98 | + } |
| 99 | + |
| 100 | + public function reponse405(): self |
| 101 | + { |
| 102 | + $this->httpCode = 405; |
| 103 | + $this->message = 'Method Not Allowed'; |
| 104 | + return $this; |
| 105 | + } |
| 106 | + |
| 107 | + public function reponse406(): self |
| 108 | + { |
| 109 | + $this->httpCode = 406; |
| 110 | + $this->message = 'Not Acceptable'; |
| 111 | + return $this; |
| 112 | + } |
| 113 | + |
| 114 | + public function reponse408(): self |
| 115 | + { |
| 116 | + $this->httpCode = 408; |
| 117 | + $this->message = 'Request Time-out'; |
| 118 | + return $this; |
| 119 | + } |
| 120 | + |
| 121 | + |
| 122 | + // 500 |
| 123 | + |
| 124 | + public function reponse500(): self |
| 125 | + { |
| 126 | + $this->httpCode = 500; |
| 127 | + $this->message = 'Internal Server Error'; |
| 128 | + return $this; |
| 129 | + } |
| 130 | + |
| 131 | + public function reponse501(): self |
| 132 | + { |
| 133 | + $this->httpCode = 501; |
| 134 | + $this->message = 'Not Implemented'; |
| 135 | + return $this; |
| 136 | + } |
| 137 | + |
| 138 | + public function reponse502(): self |
| 139 | + { |
| 140 | + $this->httpCode = 502; |
| 141 | + $this->message = 'Bad Gateway'; |
| 142 | + return $this; |
| 143 | + } |
| 144 | + |
| 145 | + public function reponse503(): self |
| 146 | + { |
| 147 | + $this->httpCode = 503; |
| 148 | + $this->message = 'Service Unavailable'; |
| 149 | + return $this; |
| 150 | + } |
| 151 | + |
| 152 | + public function reponse505(): self |
| 153 | + { |
| 154 | + $this->httpCode = 505; |
| 155 | + $this->message = 'HTTP Version not supported'; |
| 156 | + return $this; |
| 157 | + } |
| 158 | + |
| 159 | + public function reponse511(): self |
| 160 | + { |
| 161 | + $this->httpCode = 511; |
| 162 | + $this->message = 'Network authentication required'; |
| 163 | + return $this; |
| 164 | + } |
| 165 | +} |
0 commit comments