Completed
Push — master ( 8f4937...fedf49 )
by smiley
03:03
created

MyAwesomeModule   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 26.92 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 7
loc 26
rs 10

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Class MyMySimpletext
4
 *
5
 * @filesource   MyAwesomeModule.php
6
 * @created      02.11.2015
7
 * @package      Example\MyModules
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2015 Smiley
10
 * @license      MIT
11
 */
12
13
namespace Example\MyModules;
14
15
use chillerlan\bbcode\Modules\ModuleInterface;
16
use Example\MyModules\MyAwesomeBaseModule;
17
18
/**
19
 * Transforms several simple text tags into HTML5 (custom)
20
 */
21
class MyAwesomeModule extends MyAwesomeBaseModule implements ModuleInterface{
22
23
	/**
24
	 * An array of tags the module is able to process
25
	 *
26
	 * @var array
27
	 * @see \chillerlan\bbcode\Modules\Tagmap::$tags
28
	 */
29
	protected $tags = ['mybbcode', 'somebbcode', 'whatever'];
30
31
	/**
32
	 * Transforms the bbcode, called from BaseModuleInterface
33
	 *
34
	 * @return string a transformed snippet
35
	 * @see \chillerlan\bbcode\Modules\BaseModuleInterface::transform()
36
	 * @internal
37
	 */
38
	public function _transform(){
39
		if(empty($this->content)){
40
			return '';
41
		}
42
43
		return '<'.$this->tag.'>'.$this->content.'</'.$this->tag.'>';
44
	}
45
46
}
47