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

OneConditionMatcher::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 OneConditionMatcher extends AbstractConditionsMatcher implements ConditionsMatcherInterface
7
{
8
    /**
9
     *
10
     * {@inheritDoc}
11
     *
12
     * @see \Mcustiel\PowerRoute\Common\Conditions\ConditionsMatcherInterface::conditionsMatches()
13
     */
14 2
    public function matches(array $conditions, ServerRequestInterface $request)
15
    {
16 2
        foreach ($conditions as $condition) {
17 2
            $inputSourceData = $this->getInputSource($condition);
18 2
            $matcherData = $this->getMatcher($condition);
19
20 2
            $inputValue = $inputSourceData->getInstance()->getValue(
21 2
                $request,
22 2
                $inputSourceData->getArgument()
23 2
            );
24
25 2
            if ($matcherData->getInstance()->match($inputValue, $matcherData->getArgument())) {
26 1
                return true;
27
            }
28 1
        }
29 1
        return false;
30
    }
31
}
32