Passed
Push — master ( 4ee9ec...849354 )
by San
04:18 queued 03:37
created

Goutte::setHttpHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Behatch\HttpCall\Request;
4
5
class Goutte extends BrowserKit
6
{
7
    /**
8
     * headers are no more stored on client, because client does not flush them when reset/restart session.
9
     * They are on Behat\Mink\Driver\BrowserKitDriver and there is no way to get them.
10
     *
11
     * @var array
12
     */
13
    private $requestHeaders = [];
14
15
    public function send($method, $url, $parameters = [], $files = [], $content = null, $headers = [])
16
    {
17
        $page = parent::send($method, $url, $parameters, $files, $content, $this->requestHeaders);
18
        $this->resetHttpHeaders();
19
20
        return $page;
21
    }
22
23
    public function getServer()
24
    {
25
        return $this->getRequest()
26
            ->server->all();
27
    }
28
29
    public function getParameters()
30
    {
31
        return $this->getRequest()
32
            ->query->all();
33
    }
34
35
    public function setHttpHeader($name, $value)
36
    {
37
        $name = strtoupper("http_$name");
38
        $this->requestHeaders[$name] = $value;
39
    }
40
41
    private function resetHttpHeaders()
42
    {
43
        $this->requestHeaders = [];
44
    }
45
}
46