Completed
Push — master ( 98a82f...7bd861 )
by Márcio Lucas R.
11s
created

Execution::end()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/**
4
 * Copyright (c) 2017. Este código foi feito por @marciioluucas, sob licença MIT
5
 */
6
namespace Phiber\Util;
7
8
use Phiber\Util\Internationalization;
9
10
/**
11
 * Classe responsável por medir o tempo de execução das tarefas.
12
 * 
13
 * @package util
14
 */
15
class Execution
16
{
17
    /**
18
     * Define o tempo de inciação de execução nesta variável
19
     */
20
    private static $time;
21
22
    /**
23
     *  Procedimento responsável por calcular o tempo incial da execução
24
     */
25
    final public static function start()
26
    {
27
        self::$time = self::getTime();
28
    }
29
30
    /**
31
     * @return mixed
32
     */
33
    final public function getTime()
34
    {
35
        return microtime(true);
36
    }
37
38
    /**
39
     * Calcula a variação do tempo (Tempo final - Tempo inical) da execução e em seguida
40
     * formata o número para 6 digitos após a vírgula.
41
     * 
42
     * @return string
43
     */
44
    final public static function end()
45
    {
46
        $finalTime     = self::getTime();
47
        $execTime      = $finalTime - self::$time;
48
        $msgTranslated = new Internationalization("seconds");
49
        
50
        return number_format($execTime, 6) . " " . $msgTranslated;
51
    }
52
}
53