CompositeMatcher::match()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 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