Completed
Push — master ( 552173...c8702c )
by Tobias
12:00 queued 43s
created

Label::placeMe()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 13
cts 13
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 12
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * Contains the component class for rendering a label.
4
 *
5
 * @copyright (C) 2018, Tobias Oetterer, Paderborn University
6
 * @license       https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 (or later)
7
 *
8
 * This file is part of the MediaWiki extension BootstrapComponents.
9
 * The BootstrapComponents extension is free software: you can redistribute it
10
 * and/or modify it under the terms of the GNU General Public License as published
11
 * by the Free Software Foundation, either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * The BootstrapComponents extension is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
21
 *
22
 * @file
23
 * @ingroup       BootstrapComponents
24
 * @author        Tobias Oetterer
25
 */
26
27
namespace BootstrapComponents\Components;
28
29
use BootstrapComponents\AbstractComponent;
30
use \Html;
31
32
/**
33
 * Class Label
34
 *
35
 * Class for component 'label'
36
 *
37
 * @see   https://github.com/oetterer/BootstrapComponents/blob/master/docs/components.md#Label
38
 * @since 1.0
39
 */
40
class Label extends AbstractComponent {
41
	/**
42
	 * @inheritdoc
43
	 *
44
	 * @param string $input
45
	 */
46 5
	public function placeMe( $input ) {
47 5
		if ( empty( $input ) ) {
48 2
			return $this->getParserOutputHelper()->renderErrorMessage( 'bootstrap-components-label-content-missing' );
49
		}
50
51
		$class = [
52 4
			'label', 'label-' . $this->getValueFor( 'color', 'default' ),
53 4
		];
54 4
		list ( $class, $style ) = $this->processCss( $class, [] );
55 4
		return Html::rawElement(
56 4
			'span',
57
			[
58 4
				'class' => $this->arrayToString( $class, ' ' ),
59 4
				'style' => $this->arrayToString( $style, ';' ),
60 4
				'id'    => $this->getId(),
61 4
			],
62
			$input
63 4
		);
64
	}
65
}