CompositeMatcher   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 1
dl 0
loc 28
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A matches() 0 9 2
A build() 0 4 1
match() 0 1 ?
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
abstract class CompositeMatcher implements MatcherInterface
20
{
21
	use Traits\PluginsTrait;
22
	protected $matchers = [];
23
	private $wasConstructed = false;
24
25 61
	public function add($matcher)
26
	{
27 61
		$this->matchers[] = $matcher;
28 61
	}
29
30 61
	public function matches($string, &$value)
31
	{
32 61
		if (!$this->wasConstructed)
33
		{
34 61
			$this->build();
35 61
			$this->wasConstructed = true;
36
		}
37 61
		return $this->match($string, $value);
38
	}
39
40 59
	protected function build()
41
	{
42
43 59
	}
44
45
	abstract protected function match($string, &$value);
46
}
47