Passed
Push — master ( 0658f3...f968a7 )
by y
02:18
created

AsanaCall   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 2
1
<?php
2
3
namespace Helix\Asana\Api\Laravel\Command;
4
5
use Helix\Asana\Api\Laravel\Facade\Asana;
6
use Illuminate\Console\Command;
7
8
final class AsanaCall extends Command {
9
10
    protected $description = 'Arbitrarily call a method on (mostly) any entity.';
11
12
    protected $signature = 'asana:call'
13
    . ' {class  : The entity class to load, relative to the Helix\\Asana namespace (e.g. "User")}'
14
    . ' {path   : The entity\'s resource path (e.g. "users/me")}'
15
    . ' {method : The method name to call (e.g. "getName", "reload")}'
16
    . ' {args*  : Any arguments for the method, separated by spaces.}';
17
18
    public function handle () {
19
        $api = Asana::getApi();
20
        $entity = $api->load($api, "Helix\\Asana\\" . $this->argument('class'), $this->argument('path'));
21
        if (!$entity) {
22
            $this->error('404');
23
            exit(1);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
24
        }
25
        var_dump($entity->{$this->argument('method')}(...$this->argument('args')));
0 ignored issues
show
Security Debugging Code introduced by
var_dump($entity->$this-...his->argument('args'))) looks like debug code. Are you sure you do not want to remove it?
Loading history...
26
        echo "\n\n";
27
    }
28
}