StyledText::transform()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 2
nc 2
nop 0
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