ParallelMatcher::match()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 11
cts 11
cp 1
rs 9.7
c 0
b 0
f 0
cc 4
nc 3
nop 2
crap 4
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL, Commercial license.
5
 *
6
 * @package maslosoft/addendum
7
 * @licence AGPL, Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]> (Meta container, further improvements, bugfixes)
9
 * @copyright Copyright (c) Maslosoft (Meta container, further improvements, bugfixes)
10
 * @copyright Copyright (c) Jan Suchal (Original version, builder, parser)
11
 * @link https://maslosoft.com/addendum/ - maslosoft addendum
12
 * @link https://code.google.com/p/addendum/ - original addendum project
13
 */
14
15
namespace Maslosoft\Addendum\Matcher;
16
17
use Maslosoft\Addendum\Interfaces\Matcher\MatcherInterface;
18
19
class ParallelMatcher extends CompositeMatcher implements MatcherInterface
20
{
21
22 59
	protected function match($string, &$value)
23
	{
24 59
		$maxLength = false;
25 59
		$result = null;
26 59
		$subValue = [];
27 59
		foreach ($this->matchers as $matcher)
28
		{
29 59
			$length = $matcher->matches($string, $subValue);
30 59
			if ($maxLength === false || $length > $maxLength)
31
			{
32 59
				$maxLength = $length;
33 59
				$result = $subValue;
34
			}
35
		}
36 59
		$value = $this->process($result);
37 59
		return $maxLength;
38
	}
39
40 59
	protected function process($value)
41
	{
42 59
		return $value;
43
	}
44
45
}
46