Completed
Push — master ( a4efda...49f2e8 )
by David
15s queued 11s
created

src/Http/RuleMatcher.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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
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 32
    public function __construct(
43
        RequestMatcherInterface $requestMatcher = null,
44
        ResponseMatcherInterface $responseMatcher = null
45
    ) {
46 32
        $this->requestMatcher = $requestMatcher;
47 32
        $this->responseMatcher = $responseMatcher;
48 32
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 27
    public function matches(Request $request, Response $response)
54
    {
55 27
        if ($this->requestMatcher && !$this->requestMatcher->matches($request)) {
56 22
            return false;
57
        }
58
59 26
        if ($this->responseMatcher && !$this->responseMatcher->matches($response)) {
60 6
            return false;
61
        }
62
63 22
        return true;
64
    }
65
}
66