DebuggableTrait::debug()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Arrayzy\Traits;
4
5
/**
6
 * Trait with helpful methods for debugging.
7
 *
8
 * @author Victor Bocharsky <[email protected]>
9
 *
10
 * @property array $elements
11
 */
12
trait DebuggableTrait
13
{
14
    /**
15
     * Outputs/returns printed array for debug.
16
     *
17
     * @param bool $return Whether return or output directly
18
     *
19
     * @return $this|string
20
     */
21 4
    public function debug($return = false)
22
    {
23 4
        if ($return) {
24 4
            return print_r($this->elements, true);
25
        }
26
27 4
        print_r($this->elements, false);
28
29 4
        return $this;
30
    }
31
32
    /**
33
     * Exports array for using in PHP scripts.
34
     *
35
     * @param bool $return Whether return or output directly
36
     *
37
     * @return $this|string
38
     *
39
     * @link http://php.net/manual/en/function.var-export.php
40
     */
41 4
    public function export($return = false)
42
    {
43 4
        if ($return) {
44 4
            return var_export($this->elements, true);
45
        }
46
47 4
        var_export($this->elements, false);
48
49 4
        return $this;
50
    }
51
}
52