Passed
Push — main ( 8e04c4...a044f3 )
by Tan
02:22
created

count_digital()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
if (!function_exists('count_digital')) {
4
    /**
5
     * Get digital count.
6
     *
7
     * @param $count
8
     *
9
     * @return string
10
     */
11
    function count_digital($count): string
12
    {
13
        if ($count < 1000) {
14
            return $count;
15
        }
16
17
        if ($count < 1000000) {
18
            return round($count / 1000, 1) . 'K';
19
        }
20
21
        return round($count / 1000000, 1) . 'M';
22
    }
23
}
24