CacheableResponseMatcher   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A matches() 0 4 1
A __construct() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCacheBundle 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\HttpCacheBundle\Http\ResponseMatcher;
13
14
use Symfony\Component\HttpFoundation\Response;
15
16
/**
17
 * Matches status codes as defined by IETF RFC 7231.
18
 *
19
 * @see https://tools.ietf.org/html/rfc7231#section-6.1
20
 */
21
class CacheableResponseMatcher implements ResponseMatcherInterface
22
{
23
    private $cacheableStatusCodes = [
24
        200, 203, 204, 206,
25
        300, 301,
26
        404, 405, 410, 414,
27
        501,
28
    ];
29
30 39
    public function __construct(array $additionalStatusCodes = [])
31
    {
32 39
        $this->cacheableStatusCodes = array_merge(
33 39
            $this->cacheableStatusCodes,
34
            $additionalStatusCodes
35
        );
36 39
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 28
    public function matches(Response $response)
42
    {
43 28
        return in_array($response->getStatusCode(), $this->cacheableStatusCodes);
44
    }
45
}
46