Completed
Push — master ( fe350e...be5f46 )
by smiley
04:14
created

StyledText   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 18 2
1
<?php
2
/**
3
 * Class StyledText
4
 *
5
 * @filesource   StyledText.php
6
 * @created      25.04.2018
7
 * @package      chillerlan\BBCode\Output\Markdown
8
 * @author       smiley <[email protected]>
9
 * @copyright    2018 smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\BBCode\Output\Markdown;
14
15
class StyledText extends MarkdownModuleAbstract{
16
17
	/**
18
	 * @var array
19
	 */
20
	protected $tags = ['b', 'c', 'del', 'i', 'em', 's', 'strong'];
21
22
	/**
23
	 * @return string
24
	 */
25
	protected function transform():string{
26
27
		if(empty($this->content)){
28
			return '';
29
		}
30
31
		$str = [
32
			'b'      => '**', // bold
33
			'c'      => '`',  // inline code
34
			'del'    => '~~', // strikethrough
35
			'em'     => '_',  // italic
36
			'i'      => '_',  // italic
37
			's'      => '~~', // strikethrough
38
			'strong' => '**', // bold
39
		][$this->tag];
40
41
		return $str.$this->content.$str;
42
	}
43
44
}
45