StrikeoutTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
parseInline() 0 1 ?
renderAbsy() 0 1 ?
A parseStrike() 0 13 2
A renderStrike() 0 4 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2014 Carsten Brandt
4
 * @license https://github.com/cebe/markdown/blob/master/LICENSE
5
 * @link https://github.com/cebe/markdown#readme
6
 */
7
8
namespace cebe\markdown\inline;
9
10
/**
11
 * Adds strikeout inline elements
12
 */
13
trait StrikeoutTrait
14
{
15
	/**
16
	 * Parses the strikethrough feature.
17
	 * @marker ~~
18
	 */
19 2
	protected function parseStrike($markdown)
20
	{
21 2
		if (preg_match('/^~~(.+?)~~/', $markdown, $matches)) {
22
			return [
23
				[
24 2
					'strike',
25 2
					$this->parseInline($matches[1])
26
				],
27 2
				strlen($matches[0])
28
			];
29
		}
30 1
		return [['text', $markdown[0] . $markdown[1]], 2];
31
	}
32
33 2
	protected function renderStrike($block)
34
	{
35 2
		return '<del>' . $this->renderAbsy($block[1]) . '</del>';
36
	}
37
38
    abstract protected function parseInline($text);
39
    abstract protected function renderAbsy($blocks);
40
}
41