]> git.mxchange.org Git - friendica.git/blobdiff - src/Network/GuzzleResponse.php
Add suggestions
[friendica.git] / src / Network / GuzzleResponse.php
index 18155d1d292901cf2ac2fea194086cdccd3d8fa6..3b41f6f6540f18d1838eed48020b6cd12eebafc9 100644 (file)
@@ -68,7 +68,7 @@ class GuzzleResponse extends Response implements IHTTPResult, ResponseInterface
                }
 
                if (!$this->isSuccess) {
-                       Logger::notice('http error', ['url' => $this->url, 'code' => $this->getReturnCode(), 'error'  => $this->error, 'callstack' => System::callstack(20)]);
+                       Logger::notice('http error', ['url' => $this->url, 'code' => $this->getReturnCode(), 'error' => $this->error, 'callstack' => System::callstack(20)]);
                        Logger::debug('debug', ['info' => $this->getHeaders()]);
                }
 
@@ -89,12 +89,7 @@ class GuzzleResponse extends Response implements IHTTPResult, ResponseInterface
        public function getContentType()
        {
                $contentTypes = $this->getHeader('Content-Type') ?? [];
-               $countTypes = count($contentTypes);
-               if ($countTypes > 0) {
-                       return $contentTypes[$countTypes - 1];
-               } else {
-                       return '';
-               }
+               return array_pop($contentTypes) ?? '';
        }
 
        /** {@inheritDoc} */
@@ -150,4 +145,10 @@ class GuzzleResponse extends Response implements IHTTPResult, ResponseInterface
        {
                return $this->isTimeout;
        }
+
+       /// @todo - fix mismatching use of "getBody()" as string here and parent "getBody()" as streaminterface
+       public function getBody(): string
+       {
+               return (string) parent::getBody();
+       }
 }