TinkerCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A fire() 0 20 2
1
<?php
2
3
/*
4
 * This file is part of Rocketeer
5
 *
6
 * (c) Maxime Fabre <[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
13
namespace Rocketeer\Console\Commands\Development;
14
15
use Psy\Shell;
16
use Rocketeer\Console\Commands\AbstractCommand;
17
use Rocketeer\Console\TinkerApplication;
18
19
/**
20
 * Debug Rocketeer's environment.
21
 */
22
class TinkerCommand extends AbstractCommand
23
{
24
    /**
25
     * The console command name.
26
     *
27
     * @var string
28
     */
29
    protected $name = 'debug:tinker';
30
31
    /**
32
     * @var string
33
     */
34
    protected $description = "Debug Rocketeer's environment";
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function fire()
40
    {
41
        $this->prepareEnvironment();
42
43
        // Check for Psysh existence
44
        if (!class_exists('Psy\Shell')) {
45
            $this->error('Psysh is a required dependency for tinker, run the following command:');
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method error does not exist on object<Rocketeer\Console...elopment\TinkerCommand>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
46
            $this->comment('$ composer require psy/psysh');
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method comment does not exist on object<Rocketeer\Console...elopment\TinkerCommand>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
47
48
            return false;
49
        }
50
51
        $shell = new Shell();
52
        $shell->setScopeVariables([
53
            'app' => new TinkerApplication($this->container),
54
            'ssh' => $this->bash,
55
        ]);
56
57
        return $shell->run();
58
    }
59
}
60