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

Basic   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 21.28 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 10
loc 47
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A br() 0 3 1
A hr() 0 3 1
A img() 0 3 1
A url() 10 10 2

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 Basic
4
 *
5
 * @filesource   Basic.php
6
 * @created      26.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 Basic extends MarkdownModuleAbstract{
16
17
	/**
18
	 * @var array
19
	 */
20
	protected $tags = ['br', 'hr', 'img', 'url'];
21
22
	/**
23
	 * @var array
24
	 */
25
	protected $singletags = ['br', 'hr'];
26
27
	/**
28
	 * @return string
29
	 */
30
	protected function br():string{
31
		return PHP_EOL;
32
	}
33
34
	/**
35
	 * @return string
36
	 */
37
	protected function hr():string{
38
		return PHP_EOL.'----'.PHP_EOL;
39
	}
40
41
	/**
42
	 * @return string
43
	 */
44
	protected function img():string{ // @todo: check url, alt
45
		return '!['.'alt'.']('.$this->content.')';
46
	}
47
48
	/**
49
	 * @return string
50
	 */
51 View Code Duplication
	protected function url():string{ // @todo linktext
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
53
		$url = filter_var($this->bbtag() ?? $this->content, FILTER_VALIDATE_URL);// @todo
54
55
		if($url){
56
			return  '[url]('.$url.')';
57
		}
58
59
		return '';
60
	}
61
}
62