Containers   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 16 3
1
<?php
2
/**
3
 * Class Containers
4
 *
5
 * @filesource   Containers.php
6
 * @created      24.04.2018
7
 * @package      chillerlan\BBCode\Output\HTML
8
 * @author       smiley <[email protected]>
9
 * @copyright    2018 smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\BBCode\Output\HTML;
14
15
class Containers extends HTMLModuleAbstract{
16
17
	/**
18
	 * @var array
19
	 */
20
	protected $tags = ['p', 'div', 'left', 'right', 'center'];
21
22
	/**
23
	 * @return string
24
	 */
25
	protected function transform():string{
26
27
		if(empty($this->content)){
28
			return '';
29
		}
30
31
		$align_attr = ['left', 'center', 'right', 'justify', 'start', 'end', 'inherit'];
32
		$tag        = $this->tagIn(['p', 'div'], 'p');
33
		$align      = $this->tagIn($align_attr, '');
34
35
		if(!$align){
36
			$align = $this->attributeIn('align', $align_attr, 'left');
37
		}
38
39
		return '<'.$tag.' class="bb-container '.$align.'">'.$this->content.'</'.$tag.'>';
40
	}
41
}
42