MailxpertStream   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A streamContextCreate() 0 4 1
A getResponseHeaders() 0 4 1
A fileGetContents() 0 7 1
1
<?php
2
/**
3
 * sources.
4
 * Date: 14/08/15
5
 */
6
7
namespace Mailxpert\HttpClients;
8
9
/**
10
 * Class MailxpertStream
11
 *
12
 * @package Mailxpert\HttpClients
13
 */
14
class MailxpertStream
15
{
16
    /**
17
     * @var resource Context stream resource instance
18
     */
19
    protected $stream;
20
21
    /**
22
     * @var array Response headers from the stream wrapper
23
     */
24
    protected $responseHeaders;
25
26
    /**
27
     * Make a new context stream reference instance
28
     *
29
     * @param array $options
30
     */
31
    public function streamContextCreate(array $options)
32
    {
33
        $this->stream = stream_context_create($options);
34
    }
35
36
    /**
37
     * The response headers from the stream wrapper
38
     *
39
     * @return array|null
40
     */
41
    public function getResponseHeaders()
42
    {
43
        return $this->responseHeaders;
44
    }
45
46
    /**
47
     * Send a stream wrapped request
48
     *
49
     * @param string $url
50
     *
51
     * @return mixed
52
     */
53
    public function fileGetContents($url)
54
    {
55
        $rawResponse = file_get_contents($url, false, $this->stream);
56
        $this->responseHeaders = $http_response_header;
57
58
        return $rawResponse;
59
    }
60
}
61