Completed
Push — master ( 0c46f2...43be64 )
by Chris
01:13
created

Output::print_variable()   C

Complexity

Conditions 7
Paths 6

Size

Total Lines 24
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 21
c 0
b 0
f 0
nc 6
nop 1
dl 0
loc 24
rs 6.7272
1
<?php
2
3
    namespace rAPId\Debug;
4
5
    class Output
6
    {
7
        /**
8
         * @param mixed  $data
9
         * @param string $identifier
10
         */
11
        public static function variable($data, $identifier = '') {
12
            echo "\n";
13
            if (!empty($identifier)) {
14
                self::print_variable_with_title($data, $identifier);
15
            } else {
16
                self::print_variable($data);
17
            }
18
        }
19
20
        private static function print_variable_with_title($data, $title) {
21
22
            echo(str_repeat('_', strlen($title)) . "_\n");
23
            echo $title . " |\n============================================================================\n";
24
            self::print_variable($data);
25
26
            echo "============================================================================\n";
27
        }
28
29
        private static function print_variable($data) {
30
            switch (gettype($data)) {
31
                case 'string':
32
                    echo 'string: "' . $data . '"';
33
                    break;
34
                case 'integer':
35
                    echo 'integer: ' . $data;
36
                    break;
37
                case 'double':
38
                    echo 'float: ' . $data;
39
                    break;
40
                case 'boolean':
41
                    echo 'booloean: ';
42
                    echo $data ? 'true' : 'false';
43
                    break;
44
                case 'NULL':
45
                    echo 'null';
46
                    break;
47
                default:
48
                    print_r($data);
49
                    break;
50
            }
51
52
            echo "\n";
53
        }
54
    }