ProxyResponseException::proxyResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 1
rs 10
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\HttpException;
15
16
/**
17
 * Wrapping an error response from the caching proxy.
18
 */
19
class ProxyResponseException extends \RuntimeException implements HttpCacheException
20
{
21
    /**
22
     * @return ProxyResponseException
23
     */
24 3
    public static function proxyResponse(HttpException $exception)
25
    {
26 3
        $message = sprintf(
27 3
            '%s error response "%s" from caching proxy',
28 3
            $exception->getResponse()->getStatusCode(),
29 3
            $exception->getResponse()->getReasonPhrase()
30
        );
31
32 3
        return new self($message, 0, $exception);
33
    }
34
}
35