@@ -249,7 +249,7 @@ class Response
249249 */
250250 public function __construct (float $ time = 0 )
251251 {
252- $ this ->startTime = (! empty ($ time )) ? $ time : \microtime (true );
252+ $ this ->startTime = (!empty ($ time )) ? $ time : \microtime (true );
253253 }
254254
255255 /**
@@ -262,7 +262,7 @@ public function __construct(float $time = 0)
262262 */
263263 public function setContentType (string $ type , string $ charset = '' ): static
264264 {
265- $ this ->contentType = $ type .((! empty ($ charset ) ? '; charset= ' .$ charset : '' ));
265+ $ this ->contentType = $ type .((!empty ($ charset ) ? '; charset= ' .$ charset : '' ));
266266
267267 return $ this ;
268268 }
@@ -300,7 +300,7 @@ public function isSent(): bool
300300 */
301301 public function setStatusCode (int $ code = 200 ): static
302302 {
303- if (! \array_key_exists ($ code , $ this ->statusCodes )) {
303+ if (!\array_key_exists ($ code , $ this ->statusCodes )) {
304304 throw new Exception ('Unknown HTTP status code ' );
305305 }
306306
@@ -413,7 +413,8 @@ public function getHeaders(): array
413413 public function addCookie (string $ name , string $ value = null , int $ expire = null , string $ path = null , string $ domain = null , bool $ secure = null , bool $ httponly = null , string $ sameSite = null ): static
414414 {
415415 $ name = strtolower ($ name );
416- $ this ->cookies [$ name ] = [
416+
417+ $ this ->cookies [] = [
417418 'name ' => $ name ,
418419 'value ' => $ value ,
419420 'expire ' => $ expire ,
@@ -436,9 +437,9 @@ public function addCookie(string $name, string $value = null, int $expire = null
436437 */
437438 public function removeCookie (string $ name ): static
438439 {
439- if ( isset ( $ this ->headers [ $ name ]) ) {
440- unset( $ this -> cookies [ $ name]) ;
441- }
440+ $ this -> cookies = array_filter ( $ this ->cookies , function ( $ cookie ) use ( $ name ) {
441+ return $ cookie [ ' name ' ] !== $ name ;
442+ });
442443
443444 return $ this ;
444445 }
@@ -477,7 +478,7 @@ public function send(string $body = ''): void
477478 ->appendCookies ()
478479 ->appendHeaders ();
479480
480- if (! $ this ->disablePayload ) {
481+ if (!$ this ->disablePayload ) {
481482 $ length = strlen ($ body );
482483
483484 $ this ->size = $ this ->size + strlen (implode ("\n" , $ this ->headers )) + $ length ;
@@ -524,7 +525,7 @@ protected function write(string $content): void
524525 */
525526 protected function end (string $ content = null ): void
526527 {
527- if (! is_null ($ content )) {
528+ if (!is_null ($ content )) {
528529 echo $ content ;
529530 }
530531 }
@@ -555,7 +556,7 @@ public function chunk(string $body = '', bool $end = false): void
555556 ->appendCookies ()
556557 ->appendHeaders ();
557558
558- if (! $ this ->disablePayload ) {
559+ if (!$ this ->disablePayload ) {
559560 $ this ->write ($ body );
560561 if ($ end ) {
561562 $ this ->disablePayload ();
@@ -578,7 +579,7 @@ protected function appendHeaders(): static
578579 $ this ->sendStatus ($ this ->statusCode );
579580
580581 // Send content type header
581- if (! empty ($ this ->contentType )) {
582+ if (!empty ($ this ->contentType )) {
582583 $ this ->addHeader ('Content-Type ' , $ this ->contentType );
583584 }
584585
@@ -734,7 +735,7 @@ public function text(string $data): void
734735 */
735736 public function json ($ data ): void
736737 {
737- if (! is_array ($ data ) && ! $ data instanceof \stdClass) {
738+ if (!is_array ($ data ) && !$ data instanceof \stdClass) {
738739 throw new \Exception ('Invalid JSON input var ' );
739740 }
740741
0 commit comments