DebuggableTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 40
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A debug() 0 10 2
A export() 0 10 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