Passed
Branch namespace (e2815a)
by Adam
02:50
created

message()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Functions for printing text.
4
 *
5
 * @author  Adam "Saibamen" Stachowicz <[email protected]>
6
 */
7
8
namespace Text;
9
10
/**
11
 * Prints how much time took some action in milliseconds.
12
 *
13
 * @param float $startTime Time when action started
14
 */
15
function printEndTime($startTime)
16
{
17
    $endTime = microtime(true) - (float) $startTime;
18
    $endTime = number_format((float) $endTime, 4, '.', '');
19
20
    message('It was done in '.$endTime.' ms.');
21
}
22
23
/**
24
 * Execute message() function if DEBUG is set to true.
25
 *
26
 * @global bool $DEBUG
27
 *
28
 * @param mixed $message Message to print if in DEBUG mode
29
 *
30
 * @see \Text\message()
31
 */
32
function debug($message)
33
{
34
    if (DEBUG) {
0 ignored issues
show
Bug introduced by
The constant Text\DEBUG was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
35
        message($message);
36
    }
37
}
38
39
/**
40
 * Prints message with new lines.
41
 *
42
 * @param mixed $message Message to print
43
 */
44
function message($message)
45
{
46
    echo "\n".$message."\n";
47
}
48