HttpCaller   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 40
ccs 4
cts 4
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getResponse() 0 7 2
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCache package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\HttpCache\Test;
13
14
use Psr\Http\Message\ResponseInterface;
15
16
/**
17
 * Provides a method for getting responses from your application.
18
 */
19
trait HttpCaller
20
{
21
    /**
22
     * HTTP client for requests to the application.
23
     *
24
     * @var HttpClient
25
     */
26
    private $httpClient;
27
28
    /**
29
     * Call a HTTP resource from your test.
30
     *
31
     * @param string $uri     HTTP URI, domain and port are added from the embedding class if not specified
32
     * @param array  $headers HTTP headers
33
     * @param string $method  HTTP method
34
     *
35
     * @return ResponseInterface
36
     */
37 33
    protected function getResponse($uri, array $headers = [], $method = 'GET')
38
    {
39 33
        if (!$this->httpClient) {
40 33
            $this->httpClient = new HttpClient($this->getHostName(), $this->getCachingProxyPort());
41
        }
42
43 33
        return $this->httpClient->getResponse($uri, $headers, $method);
44
    }
45
46
    /**
47
     * Get the default host name to use.
48
     *
49
     * @return string
50
     */
51
    abstract protected function getHostName();
52
53
    /**
54
     * Get the default port to use.
55
     *
56
     * @return string
57
     */
58
    abstract protected function getCachingProxyPort();
59
}
60