CallRoute   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 28
c 1
b 1
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fire() 0 8 1
A getOptions() 0 7 1
1
<?php namespace App\Console\Commands;
2
3
use Illuminate\Console\Command;
4
use Symfony\Component\Console\Input\InputOption;
5
use Illuminate\Http\Request;
6
7
/**
8
 * example usage: php artisan route:call --token=bdf22e409d051ec2c311027438066659b2a2a304 --uri=api/v1/customerservice/download-data
9
 */
10
11
class CallRoute extends Command {
12
13
	protected $name = 'route:call';
14
	protected $description = 'Call route from CLI';
15
16
	public function __construct()
17
	{
18
		parent::__construct();
19
	}
20
21
	public function fire()
22
	{
23
		$request = Request::create((string) $this->option('uri'), 'GET');
24
		$request->headers->set('X-Authorization', $this->option('token'));
25
		$this->info(strip_tags(
26
			app()['Illuminate\Contracts\Http\Kernel']->handle($request)
27
		));
28
	}
29
30
	protected function getOptions()
31
	{
32
		return [
33
			['token', null, InputOption::VALUE_REQUIRED, 'The auth token', null],
34
			['uri', null, InputOption::VALUE_REQUIRED, 'The path of the route to be called', null],
35
		];
36
	}
37
38
}
39