Code   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 19 2
1
<?php
2
/**
3
 * Class Code
4
 *
5
 * @filesource   Code.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 Code extends MarkdownModuleAbstract{
16
17
	/**
18
	 * @var array
19
	 */
20
	protected $tags = ['noparse', 'code', 'pre', 'css', 'php', 'sql', 'xml', 'html', 'js', 'json'];
21
22
	/**
23
	 * @var array
24
	 */
25
	protected $noparse = ['noparse', 'code', 'pre', 'css', 'php', 'sql', 'xml', 'html', 'js', 'json'];
26
27
	/**
28
	 * @return string
29
	 */
30
	protected function transform():string{
31
32
		if(empty($this->content)){
33
			return '';
34
		}
35
36
		$this->clearPseudoClosingTags();
37
38
		$exceptions = [
39
			'js'      => 'javascript',
40
			'pre'     => '',
41
			'code'    => '',
42
			'noparse' => '',
43
		];
44
45
		$lang = $exceptions[$this->tag] ?? $this->tag;
46
47
		return PHP_EOL.'```'.$lang.PHP_EOL.$this->content.PHP_EOL.'```'.PHP_EOL;
48
	}
49
50
}
51