Code Duplication    Length = 26-26 lines in 2 locations

src/Common/Conditions/AllConditionsMatcher.php 1 location

@@ 7-32 (lines=26) @@
4
5
use Psr\Http\Message\ServerRequestInterface;
6
7
class AllConditionsMatcher extends AbstractConditionsMatcher implements ConditionsMatcherInterface
8
{
9
    /**
10
     * {@inheritdoc}
11
     *
12
     * @see \Mcustiel\PowerRoute\Common\Conditions\ConditionsMatcherInterface::conditionsMatches()
13
     */
14
    public function matches(array $conditions, ServerRequestInterface $request)
15
    {
16
        foreach ($conditions as $condition) {
17
            $inputSourceData = $this->getInputSource($condition);
18
            $matcherData = $this->getMatcher($condition);
19
20
            $inputValue = $inputSourceData->getInstance()->getValue(
21
                $request,
22
                $inputSourceData->getArgument()
23
            );
24
25
            if (!$matcherData->getInstance()->match($inputValue, $matcherData->getArgument())) {
26
                return false;
27
            }
28
        }
29
30
        return true;
31
    }
32
}
33

src/Common/Conditions/OneConditionMatcher.php 1 location

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