@@ -30,14 +30,13 @@ public function sendRequest(RequestInterface $request): ResponseInterface
3030 if ($ cookies ) {
3131 if ($ request ->hasHeader ('Cookie ' )) {
3232 foreach (explode (', ' , $ request ->getHeaderLine ('Cookie ' )) as $ line ) {
33- $ line = trim ($ line );
34- list ($ name , $ value ) = array_replace ([null , null ], explode ('= ' , $ line , 2 ));
35- $ name = trim ($ name );
36- $ value = trim ($ value );
37- if (!$ name || !$ value ) {
33+ [$ headerCookieName , $ headerCookieValue ] = array_replace (['' , '' ], explode ('= ' , trim ($ line ), 2 ));
34+ $ headerCookieName = trim ($ headerCookieName );
35+ $ headerCookieValue = trim ($ headerCookieValue );
36+ if ($ headerCookieName === '' || $ headerCookieValue === '' ) {
3837 continue ;
3938 }
40- $ cookies [$ name ] = $ value ;
39+ $ cookies [$ headerCookieName ] = $ headerCookieValue ;
4140 }
4241 }
4342 foreach ($ cookies as $ cookie => $ value ) {
@@ -62,18 +61,18 @@ public function __destruct()
6261 * @param string $header
6362 * @param string $domain
6463 */
65- private function setCookieFromHeader (string $ header , string $ domain )
64+ private function setCookieFromHeader (string $ header , string $ domain ): void
6665 {
6766 $ arr = explode ('; ' , $ header );
6867 $ cookies = [];
6968 $ path = '/ ' ;
7069 $ expires = 0 ;
7170 $ secure = false ;
7271 foreach ($ arr as $ item ) {
73- list ( $ key , $ value ) = array_replace ([ '' , '' ], explode ('= ' , $ item , 2 ) );
74- $ key = trim ($ key );
75- $ value = trim ($ value );
76- switch (strtolower ( $ key) ) {
72+ $ keyValue = explode ('= ' , $ item , 2 );
73+ $ key = strtolower ( trim ($ keyValue [ 0 ]) );
74+ $ value = trim ($ keyValue [ 1 ] ?? '' );
75+ switch ($ key ) {
7776 case 'domain ' :
7877 if ($ value ) {
7978 $ domain = $ value ;
0 commit comments