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

NativeHttpClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 0
dl 0
loc 26
ccs 0
cts 10
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A send() 0 20 2
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