Completed
Pull Request — master (#22)
by De Cramer
02:13
created

Time   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 22
rs 10
c 0
b 0
f 0
ccs 0
cts 18
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A MStoTM() 0 9 2
A TMtoMS() 0 9 2
1
<?php
2
3
namespace eXpansion\Core\Helpers;
4
5
class Time
6
{
7
    public static function MStoTM($string)
8
    {
9
        $timeLimit = explode(":", trim($string));
10
        if (count($timeLimit) == 1) {
11
            return intval($timeLimit[0] * 1000);
12
        } else {
13
            return intval($timeLimit[0] * 60 * 1000) + intval($timeLimit[1] * 1000);
14
        }
15
    }
16
17
    public static function TMtoMS($time, $milliseconds = false)
18
    {
19
        $time = intval($time);
20
        $ms = "";
21
        if ($milliseconds) {
22
            $ms = ":" . str_pad(($time % 1000), 3, '0', STR_PAD_LEFT);
23
        }
24
        return gmdate("i:s", $time / 1000) . $ms;
25
    }
26
}
27