Completed
Push — master ( e54741...21bf2c )
by WEBEWEB
04:15 queued 16s
created

BadgeComponentTwigExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A bootstrapBadgeFunction() 0 3 1
A getFunctions() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of the bootstrap-bundle package.
5
 *
6
 * (c) 2018 NdC/WBW
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\BootstrapBundle\Twig\Extension\Component;
13
14
use Twig_SimpleFunction;
15
use WBW\Library\Core\Utility\ArrayUtility;
16
17
/**
18
 * Badge component Twig extension.
19
 *
20
 * @author NdC/WBW <https://github.com/webeweb/>
21
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component
22
 * @final
23
 */
24
final class BadgeComponentTwigExtension extends AbstractComponentTwigExtension {
25
26
	/**
27
	 * Service name.
28
	 *
29
	 * @var string
30
	 */
31
	const SERVICE_NAME = "webeweb.bundle.bootstrapbundle.twig.extension.component.badge";
32
33
	/**
34
	 * Displays a Bootstrap badge.
35
	 *
36
	 * @param array $args The arguments.
37
	 * @return string Returns the Bootstrap badge.
38
	 */
39
	public function bootstrapBadgeFunction(array $args = []) {
40
		return $this->bootstrapBadge(ArrayUtility::get($args, "content"));
41
	}
42
43
	/**
44
	 * Get the Twig functions.
45
	 *
46
	 * @return array Returns the Twig functions.
47
	 */
48
	public function getFunctions() {
49
		return [
50
			new Twig_SimpleFunction("bootstrapBadge", [$this, "bootstrapBadgeFunction"], ["is_safe" => ["html"]]),
51
		];
52
	}
53
54
}
55