Completed
Push — master ( c93e0a...f87b82 )
by Mario
09:30 queued 03:59
created

NativeHttpClient::send()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 20
ccs 0
cts 10
cp 0
rs 9.4285
cc 2
eloc 11
nc 2
nop 2
crap 6
1
<?php
2
3
namespace Marek\Toggable\Http\Client;
4
5
/**
6
 * Class NativeHttpClient
7
 * @package Marek\Toggable\Http\Client
8
 */
9
class NativeHttpClient implements HttpClientInterface
10
{
11
    /**
12
     * @inheritDoc
13
     */
14
    public function send($uri, $options)
15
    {
16
        $context = stream_context_create($options);
17
18
        $stream = @fopen($uri, 'r', false, $context);
19
20
        if ($stream == false) {
21
            return array();
22
        }
23
24
        $data = stream_get_contents($stream);
25
26
        $metadata = stream_get_meta_data($stream);
27
        fclose($stream);
28
29
        return array(
30
            'data'      => $data,
31
            'metadata'  => $metadata,
32
        );
33
    }
34
}
35