RequestMatcher   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A matches() 0 12 5
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\UserContext;
13
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
16
17
class RequestMatcher implements RequestMatcherInterface
18
{
19
    private $method;
20
21
    private $accept;
22
23 22
    public function __construct($accept = 'application/vnd.fos.user-context-hash', $method = null)
24
    {
25 22
        $this->accept = $accept;
26 22
        $this->method = $method;
27 22
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 20
    public function matches(Request $request)
33
    {
34 20
        if (null !== $this->accept && $this->accept != $request->headers->get('accept', null)) {
35 18
            return false;
36
        }
37
38 3
        if (null !== $this->method && $this->method != $request->getMethod()) {
39 1
            return false;
40
        }
41
42 2
        return true;
43
    }
44
}
45