Completed
Push — master ( 0de349...246355 )
by David
13s
created

CacheableResponseMatcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 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 21
    public function __construct(array $additionalStatusCodes = [])
31
    {
32 21
        $this->cacheableStatusCodes = array_merge(
33 21
            $this->cacheableStatusCodes,
34
            $additionalStatusCodes
35
        );
36 21
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 11
    public function matches(Response $response)
42
    {
43 11
        return in_array($response->getStatusCode(), $this->cacheableStatusCodes);
44
    }
45
}
46