Completed
Branch wip/litedown (e234a3)
by Josh
31:46 queued 18:30
created

Strikethrough   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 22 3
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2017 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Plugins\Litedown\Parser\Passes;
9
10
class Strikethrough extends AbstractPass
11
{
12
	/**
13
	* {@inheritdoc}
14
	*/
15 263
	public function parse()
16
	{
17 263
		$pos = $this->text->indexOf('~~');
18 263
		if ($pos === false)
19 263
		{
20 256
			return;
21
		}
22
23 7
		preg_match_all(
24 7
			'/~~[^\\x17]+?~~/',
25 7
			$this->text,
26 7
			$matches,
27 7
			PREG_OFFSET_CAPTURE,
28
			$pos
29 7
		);
30 7
		foreach ($matches[0] as list($match, $matchPos))
31
		{
32 5
			$matchLen = strlen($match);
33
34 5
			$this->parser->addTagPair('DEL', $matchPos, 2, $matchPos + $matchLen - 2, 2);
35 7
		}
36
	}
37
}