ideas_status_icon   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 12
c 2
b 0
f 0
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A getFunctions() 0 4 1
A get_status_icon() 0 13 1
1
<?php
2
/**
3
 *
4
 * Ideas extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\ideas\template\twig\extension;
12
13
use phpbb\ideas\ext;
14
15
class ideas_status_icon extends \Twig\Extension\AbstractExtension
0 ignored issues
show
Bug introduced by
The type Twig\Extension\AbstractExtension was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
{
17
	/**
18
	 * Get the name of this extension
19
	 *
20
	 * @return string
21
	 */
22
	public function getName()
23
	{
24
		return 'ideas_status_icon';
25
	}
26
27
	/**
28
	 * {@inheritDoc}
29
	 */
30
	public function getFunctions()
31
	{
32
		return [
33
			new \Twig\TwigFunction('ideas_status_icon', [$this, 'get_status_icon']),
0 ignored issues
show
Bug introduced by
The type Twig\TwigFunction was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34
		];
35
	}
36
37
	/**
38
	 * Generate a Font Awesome icon class name given an integer input
39
	 * representing one of the Ideas Statuses.
40
	 *
41
	 * @return string Status class name or empty string if no match found.
42
	 */
43
	public function get_status_icon()
44
	{
45
		$args = func_get_args();
46
47
		$icons = [
48
			ext::$statuses['NEW']         => 'fa-lightbulb-o',
49
			ext::$statuses['IN_PROGRESS'] => 'fa-code-fork',
50
			ext::$statuses['IMPLEMENTED'] => 'fa-check',
51
			ext::$statuses['DUPLICATE']   => 'fa-files-o',
52
			ext::$statuses['INVALID']     => 'fa-ban',
53
		];
54
55
		return $icons[$args[0]] ?? '';
56
	}
57
}
58