Passed
Push — master ( 63eb61...20c591 )
by San
04:59
created

Goutte   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 7 1
A setHttpHeader() 0 5 1
A resetHttpHeaders() 0 4 1
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, array_merge($headers, $this->requestHeaders));
18
        $this->resetHttpHeaders();
19
20
        return $page;
21
    }
22
23
    public function setHttpHeader($name, $value)
24
    {
25
        $name = strtoupper("http_$name");
26
        $this->requestHeaders[$name] = $value;
27
    }
28
29
    protected function resetHttpHeaders()
30
    {
31
        $this->requestHeaders = [];
32
    }
33
}
34