Completed
Pull Request — develop (#1328)
by Naveen
03:36
created

Badge_Generator::generate_html()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Wordlift\Vocabulary\Menu\Badge;
4
5
6
/**
7
 * Class Badge_Generator
8
 * @since 3.30.0
9
 * @package Wordlift\Vocabulary\Menu\Badge
10
 */
11
class Badge_Generator {
12
13
	/**
14
	 * Returns the term count which needs to be shown on ui.
15
	 * @param $number
16
	 *
17
	 * @return int
18
	 */
19
	public static function get_ui_count( $number ) {
20
21
		$number = (int) $number;
22
23
		if ( $number < 100 ) {
24
			return $number;
25
		}
26
27
		return 100;
28
	}
29
30
	public static function generate_html( $number ) {
31
		$round = self::get_ui_count( $number );
32
		$count_string = $round < 100 ? "$round" : "$round+";
33
		return "<span class=\"wl-admin-menu-badge\">$count_string</span>";
34
	}
35
36
37
}