Passed
Push — master ( 03db17...536cbd )
by Josh
02:43
created

AbstractParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 8
c 1
b 0
f 1
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 9 2
1
<?php declare(strict_types=1);
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2023 The s9e authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Plugins\AbstractStaticUrlReplacer;
9
10
use s9e\TextFormatter\Plugins\ParserBase;
11
12
class AbstractParser extends ParserBase
13
{
14
	protected int $tagPriority = 0;
15
16
	/**
17
	* {@inheritdoc}
18
	*/
19
	public function parse($text, array $matches)
20
	{
21
		$tagName  = $this->config['tagName'];
22
		$attrName = $this->config['attrName'];
23
		$prio     = $this->tagPriority;
24
		foreach ($matches as $m)
25
		{
26
			$this->parser->addTagPair($tagName, $m[0][1], 0, $m[0][1] + strlen($m[0][0]), 0, $prio)
27
			             ->setAttribute($attrName, $m[0][0]);
28
		}
29
	}
30
}