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

ProxyUnreachableException::proxyUnreachable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 13
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 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\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