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

FirePHP::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php namespace nyx\diagnostics\debug\dumpers;
2
3
// Vendor dependencies
4
use FirePHP as Base;
5
6
// Internal dependencies
7
use nyx\diagnostics\debug\interfaces;
8
9
/**
10
 * FirePHP Dumper
11
 *
12
 * A bridge allowing to use FirePHP as a Dumper within the Debug subcomponent. Check out FirePHP itself on
13
 * Github at {@see https://github.com/firephp/firephp-core}.
14
 *
15
 * Requires:
16
 * - Package: firephp/firephp-core (available as suggestion for nyx/diagnostics within Composer)
17
 *
18
 * @version     0.1.0
19
 * @author      Michal Chojnacki <[email protected]>
20
 * @copyright   2012-2017 Nyx Dev Team
21
 * @link        https://github.com/unyx/nyx
22
 * @todo        Readable breaks between each variable dump.
23
 * @todo        Adjust the settings locally and apply them on each call to dump_r().
24
 */
25
class FirePHP implements interfaces\Dumper
26
{
27
    /**
28
     * @var Base    The underlying FirePHP instance.
29
     */
30
    private $dumper;
31
32
    /**
33
     * Constructs a new Dumper bridge for a FirePHP instance.
34
     *
35
     * @param   Dumper  $dumper     An already instantiated FirePHP instance or null to construct a new one
36
     *                              lazily upon the first call to self::dump().
37
     */
38
    public function __construct(Base $dumper = null)
39
    {
40
        $this->dumper = $dumper;
41
    }
42
43
    /**
44
     * {@inheritDoc}
45
     */
46
    public function __invoke(...$vars)
47
    {
48
        if (null === $this->dumper) {
49
            $this->dumper = Base::getInstance(false);
50
        }
51
52
        return call_user_func([$this->dumper, "fb"], ...$vars);
53
    }
54
55
    /**
56
     * Returns the underlying FirePHP instance.
57
     *
58
     * @return  Base|null
59
     */
60
    public function expose()
61
    {
62
        return $this->dumper;
63
    }
64
}
65