Completed
Push — master ( 614d47...764102 )
by D
04:29
created

src/ReponseInterface.php (4 issues)

Labels
Severity
1
<?php
2
3
namespace PiedWeb\Curl;
4
5
interface ResponseInterface
6
{
7
    public function getContent();
8
9
    public function getHeaders(bool $returnArray = true);
10
11
    public function getUrl();
12
13
    public function getEffectiveUrl();
14
15
    public function getCookies()
16
    {
17
        if (isset($this->headers)) {
0 ignored issues
show
Accessing headers on the interface PiedWeb\Curl\ResponseInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
18
            $headers = $this->getHeaders();
19
20
            if (isset($headers['Set-Cookie'])) {
21
                if (is_array($headers['Set-Cookie'])) {
22
                    return implode('; ', $headers['Set-Cookie']);
23
                } else {
24
                    return $headers['Set-Cookie'];
25
                }
26
            }
27
        }
28
    }
29
30
    /**
31
     * Get information regarding the request.
32
     *
33
     * @param string $key to get
34
     *
35
     * @return string|array
36
     */
37
    public function getInfo(?string $key = null)
38
    {
39
        return $key ? (isset($this->info[$key]) ? $this->info[$key] : null) : $this->info;
0 ignored issues
show
Accessing info on the interface PiedWeb\Curl\ResponseInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
40
    }
41
42
    public function getStatusCode()
43
    {
44
        return $this->info['http_code'];
0 ignored issues
show
Accessing info on the interface PiedWeb\Curl\ResponseInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
45
    }
46
47
    public function getContentType()
48
    {
49
        return $this->info['content_type'];
0 ignored issues
show
Accessing info on the interface PiedWeb\Curl\ResponseInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
50
    }
51
52
    public function getMimeType()
53
    {
54
        $headers = Helper::parseHeader($this->getContentType());
55
56
        return $headers[0][0] ?? null;
57
    }
58
}
59