Completed
Push — master ( 7234ed...646297 )
by Théo
13:26
created

PsyshFacade::setContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the PsyshBundle package.
5
 *
6
 * (c) Théo FIDRY <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Fidry\PsyshBundle;
13
14
use Psy\Shell;
15
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
16
use Symfony\Component\DependencyInjection\ContainerInterface;
17
18
/**
19
 * @author Théo FIDRY <[email protected]>
20
 */
21
final class PsyshFacade implements ContainerAwareInterface
22
{
23
    /**
24
     * @var Shell
25
     */
26
    private static $shell;
27
28
    /**
29
     * @var ContainerInterface|null
30
     */
31
    private static $container;
32
33
    public static function init()
34
    {
35
        if (null !== self::$shell) {
36
            return;
37
        }
38
39
        if (null === self::$container) {
40
            throw new \RuntimeException('Cannot initialize the facade without a container.');
41
        }
42
43
        self::$shell = self::$container->get('psysh.shell');
44
    }
45
46
    public static function debug(array $variables = [], $bind = null)
47
    {
48
        $_variables = array_merge(self::$shell->getScopeVariables(), $variables);
49
50
        extract(
51
            self::$shell->debug($_variables, $bind)
0 ignored issues
show
Bug introduced by
self::$shell->debug($_variables, $bind) cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
52
        );
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58
    public function setContainer(ContainerInterface $container = null)
59
    {
60
        self::$container = $container;
61
    }
62
}
63