Generic::getArguments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php namespace App\Console\Commands;
2
3
use App\Console\Commands\BaseCommand;
4
use Symfony\Component\Console\Input\InputOption;
5
use Symfony\Component\Console\Input\InputArgument;
6
7
class Generic extends BaseCommand {
8
9
	/**
10
	 * The console command name.
11
	 *
12
	 * @var string
13
	 */
14
	protected $name = 'generic';
15
16
	/**
17
	 * The console command description.
18
	 *
19
	 * @var string
20
	 */
21
	protected $description = 'Helper for running a Model\s method from an artisan command.';
22
23
	/**
24
	 * Create a new command instance.
25
	 */
26
	public function __construct()
27
	{
28
		parent::__construct();
29
	}
30
31
	/**
32
	 * Execute the console command.
33
	 *
34
	 * @return mixed
35
	 */
36
	public function fire()
37
	{
38
		$data = \App::make($this->argument('model'))->{$this->argument('method')}($this->argument('arguments'));
39
		$output = (is_array($data) ? implode("\n", $data) : $data);		
40
		
41
		$this->output($output, false);
42
	}
43
44
	/**
45
	 * Get the console command arguments.
46
	 *
47
	 * @return array
48
	 */
49
	protected function getArguments()
50
	{
51
		return [
52
			['model', InputArgument::REQUIRED, 'model name, with namespaces escaped (e.g. App\\\\LaravelRestCms\\\\SomeFolder\\\\SomeClass)'],
53
			['method', InputArgument::REQUIRED, 'method name'],
54
			['arguments'],
55
		];
56
	}
57
58
	/**
59
	 * Get the console command options.
60
	 *
61
	 * @return array
62
	 */
63
	protected function getOptions()
64
	{
65
		return [
66
		];
67
	}
68
69
}
70