Completed
Push — master ( 2be245...cb8b53 )
by David
16s queued 11s
created

UnsafeRequestMatcher::matches()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 3
cts 4
cp 0.75
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.0625
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\RequestMatcher;
13
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
16
use Symfony\Component\HttpKernel\Kernel;
17
18
class UnsafeRequestMatcher implements RequestMatcherInterface
19
{
20 22
    public function matches(Request $request)
21
    {
22
        // hack needed for compatibility with SF 3.4 => 4.3
23
        // sf 3.4 => isMethodSafe(false)
24
        // sf 4.3 => isMethodSafe() or isMethodSafe(false)
25
        // sf 4.4 => isMethodSafe()
26 22
        if (Kernel::VERSION_ID >= 40300) {
27 22
            return !$request->isMethodSafe();
28
        } else {
29
            return !$request->isMethodSafe(false);
30
        }
31
    }
32
}
33