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

Badge_Generator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_ui_count() 0 10 2
A generate_html() 0 5 2
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
}