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

Execution   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A start() 0 4 1
A getTime() 0 4 1
A end() 0 8 1
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