Passed
Branch master (718b20)
by y
07:49
created

AsanaCall::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
rs 10
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);
24
        }
25
        var_dump($entity->{$this->argument('method')}(...$this->argument('args')));
26
        echo "\n\n";
27
    }
28
}