RuleMatcher   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
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 40
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 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\Http;
13
14
use FOS\HttpCacheBundle\Http\ResponseMatcher\ResponseMatcherInterface;
15
use Symfony\Component\HttpFoundation\Request;
16
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
17
use Symfony\Component\HttpFoundation\Response;
18
19
/**
20
 * Combines a RequestMatcherInterface and a ResponseMatcherInterface.
21
 *
22
 * Both must match for the RuleMatcher to match.
23
 *
24
 * @author David Buchmann <[email protected]>
25
 */
26
class RuleMatcher implements RuleMatcherInterface
27
{
28
    /**
29
     * @var RequestMatcherInterface
30
     */
31
    private $requestMatcher;
32
33
    /**
34
     * @var ResponseMatcherInterface
35
     */
36
    private $responseMatcher;
37
38
    /**
39
     * @param RequestMatcherInterface  $requestMatcher|null  Request matcher
0 ignored issues
show
Documentation introduced by
There is no parameter named $requestMatcher|null. Did you maybe mean $requestMatcher?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
40
     * @param ResponseMatcherInterface $responseMatcher|null Response matcher
0 ignored issues
show
Documentation introduced by
There is no parameter named $responseMatcher|null. Did you maybe mean $responseMatcher?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
41
     */
42 34
    public function __construct(
43
        RequestMatcherInterface $requestMatcher = null,
44
        ResponseMatcherInterface $responseMatcher = null
45
    ) {
46 34
        $this->requestMatcher = $requestMatcher;
47 34
        $this->responseMatcher = $responseMatcher;
48 34
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 26
    public function matches(Request $request, Response $response)
54
    {
55 26
        if ($this->requestMatcher && !$this->requestMatcher->matches($request)) {
56 21
            return false;
57
        }
58
59 25
        if ($this->responseMatcher && !$this->responseMatcher->matches($response)) {
60 5
            return false;
61
        }
62
63 22
        return true;
64
    }
65
}
66