Passed
Pull Request — master (#514)
by Fabien
10:39
created

ProxyUnreachableException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A proxyUnreachable() 0 12 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\NetworkException;
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
     * @return ProxyUnreachableException
24
     */
25 3
    public static function proxyUnreachable(NetworkException $requestException)
26
    {
27 3
        $message = sprintf(
28 3
            'Request to caching proxy at %s failed with message "%s"',
29 3
            $requestException->getRequest()->getHeaderLine('Host'),
30 3
            $requestException->getMessage()
31
        );
32
33 3
        return new self(
34 3
            $message,
35 3
            0,
36
            $requestException
37
        );
38
    }
39
}
40