Completed
Pull Request — master (#364)
by Alessandro
04:31
created

ProxyUnreachableException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 22
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A proxyUnreachable() 0 14 1
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\Exception;
13
14
use Http\Client\Exception\RequestException;
15
16
/**
17
 * Thrown when a request to the reverse caching proxy fails to establish a
18
 * connection.
19
 */
20
class ProxyUnreachableException extends \RuntimeException implements HttpCacheException
21
{
22
    /**
23
     * @param RequestException $requestException
24
     *
25
     * @return ProxyUnreachableException
26
     */
27
    public static function proxyUnreachable(RequestException $requestException)
28
    {
29
        $message = sprintf(
30
            'Request to caching proxy at %s failed with message "%s"',
31
            $requestException->getRequest()->getHeaderLine('Host'),
32
            $requestException->getMessage()
33
        );
34
35
        return new self(
36
            $message,
37
            0,
38
            $requestException
39
        );
40
    }
41
}
42