PsyshFacade   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 12 3
A debug() 0 8 1
A setContainer() 0 4 1
1
<?php declare(strict_types=1);
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 RuntimeException;
16
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
17
use Symfony\Component\DependencyInjection\ContainerInterface;
18
use function array_merge;
19
20
/**
21
 * @author Théo FIDRY <[email protected]>
22
 */
23
final class PsyshFacade implements ContainerAwareInterface
24
{
25
    /**
26
     * @var Shell
27
     */
28
    private static $shell;
29
30
    /**
31
     * @var ContainerInterface|null
32
     */
33
    private static $container;
34
35
    public static function init(): void
36
    {
37
        if (null !== self::$shell) {
38
            return;
39
        }
40
41
        if (null === self::$container) {
42
            throw new RuntimeException('Cannot initialize the facade without a container.');
43
        }
44
45
        self::$shell = self::$container->get('psysh.shell');
46
    }
47
48
    public static function debug(array $variables = [], $bind = null)
49
    {
50
        self::init();
51
52
        $_variables = array_merge(self::$shell->getScopeVariables(), $variables);
53
54
        self::$shell::debug($_variables, $bind);
0 ignored issues
show
Deprecated Code introduced by
The method Psy\Shell::debug() has been deprecated with message: will be removed in 1.0. Use \Psy\debug instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
55
    }
56
57
    public function setContainer(ContainerInterface $container = null): void
58
    {
59
        self::$container = $container;
60
    }
61
}
62