Completed
Push — master ( 74ffa0...ed410a )
by Mariano
10:21
created

AllConditionsMatcher::matches()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 17
ccs 12
cts 12
cp 1
rs 9.4285
cc 3
eloc 10
nc 3
nop 2
crap 3
1
<?php
2
namespace Mcustiel\PowerRoute\Common\Conditions;
3
4
use Psr\Http\Message\ServerRequestInterface;
5
6
class AllConditionsMatcher extends AbstractConditionsMatcher implements ConditionsMatcherInterface
7
{
8
    /**
9
     *
10
     * {@inheritDoc}
11
     *
12
     * @see \Mcustiel\PowerRoute\Common\Conditions\ConditionsMatcherInterface::conditionsMatches()
13
     */
14 3
    public function matches(array $conditions, ServerRequestInterface $request)
15
    {
16 3
        foreach ($conditions as $condition) {
17 3
            $inputSourceData = $this->getInputSource($condition);
18 3
            $matcherData = $this->getMatcher($condition);
19
20 3
            $inputValue = $inputSourceData->getInstance()->getValue(
21 3
                $request,
22 3
                $inputSourceData->getArgument()
23 3
            );
24
25 3
            if (!$matcherData->getInstance()->match($inputValue, $matcherData->getArgument())) {
26 2
                return false;
27
            }
28 1
        }
29 1
        return true;
30
    }
31
}
32