InstagramStream::getResponseHeaders()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Maztech\HttpClients;
4
5
/**
6
 * Class InstagramStream
7
 *
8
 * Abstraction for the procedural stream elements so that the functions can be
9
 * mocked and the implementation can be tested.
10
 *
11
 * @package Instagram
12
 */
13
class InstagramStream
14
{
15
    /**
16
     * @var resource Context stream resource instance
17
     */
18
    protected $stream;
19
20
    /**
21
     * @var array Response headers from the stream wrapper
22
     */
23
    protected $responseHeaders = [];
24
25
    /**
26
     * Make a new context stream reference instance
27
     *
28
     * @param array $options
29
     */
30
    public function streamContextCreate(array $options)
31
    {
32
        $this->stream = stream_context_create($options);
33
    }
34
35
    /**
36
     * The response headers from the stream wrapper
37
     *
38
     * @return array
39
     */
40
    public function getResponseHeaders()
41
    {
42
        return $this->responseHeaders;
43
    }
44
45
    /**
46
     * Send a stream wrapped request
47
     *
48
     * @param string $url
49
     *
50
     * @return mixed
51
     */
52
    public function fileGetContents($url)
53
    {
54
        $rawResponse = file_get_contents($url, false, $this->stream);
55
        $this->responseHeaders = $http_response_header ?: [];
56
57
        return $rawResponse;
58
    }
59
}
60