Completed
Push — master ( 9a9f60...45932f )
by Michał
02:53
created

Ladybug::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace nyx\diagnostics\debug\dumpers;
2
3
// Vendor dependencies
4
use Ladybug\Dumper;
5
6
// Internal dependencies
7
use nyx\diagnostics\debug\interfaces;
8
9
/**
10
 * Ladybug Dumper
11
 *
12
 * A bridge allowing to use Ladybug as a Dumper within the Debug subcomponent. The class also gives you access
13
 * to the underlying Ladybug\Dumper instance if you want to customize its settings. Check out Ladybug itself on
14
 * Github at {@see https://github.com/raulfraile/Ladybug}.
15
 *
16
 * Requires:
17
 * - Package: raulfraile/ladybug (available as suggestion for nyx/diagnostics within Composer)
18
 *
19
 * @version     0.1.0
20
 * @author      Michal Chojnacki <[email protected]>
21
 * @copyright   2012-2017 Nyx Dev Team
22
 * @link        https://github.com/unyx/nyx
23
 */
24
class Ladybug implements interfaces\Dumper
25
{
26
    /**
27
     * @var Dumper  The underlying instance of the Ladybug\Dumper.
28
     */
29
    private $dumper;
30
31
    /**
32
     * Constructs a new Dumper bridge for an Ladybug\Dumper instance.
33
     *
34
     * @param   Dumper  $dumper     An already instantiated Ladybug\Dumper instance or null to construct a new one.
35
     */
36
    public function __construct(Dumper $dumper = null)
37
    {
38
        $this->dumper = $dumper ?: new Dumper;
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     */
44
    public function __invoke(...$vars)
45
    {
46
        // @todo Actual output handling.
47
        echo call_user_func([$this->dumper, "dump"], ...$vars);
48
    }
49
50
    /**
51
     * Returns the underlying Ladybug\Dumper instance.
52
     *
53
     * @return  Dumper
54
     * @todo    Rename to getLadybug or...?
55
     */
56
    public function expose()
57
    {
58
        return $this->dumper;
59
    }
60
}
61