MoipAuthCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace SOSTheBlack\Moip\Commands;
2
3
use Moip;
4
use Illuminate\Console\Command;
5
6
class MoipAuthCommand extends Command {
7
8
	/**
9
	 * The console command name.
10
	 *
11
	 * @var string
12
	 */
13
	protected $name = 'moip:auth';
14
15
	/**
16
	 * The console command description.
17
	 *
18
	 * @var string
19
	 */
20
	protected $description = 'Sets environment and credentials';
21
22
	/**
23
	 * Create a new command instance.
24
	 */
25
	public function __construct()
26
	{
27
		parent::__construct();
28
	}
29
30
	/**
31
	 * Execute the console command.
32
	 *
33
	 * @return void
34
	 */
35
	public function fire()
36
	{
37
		$environment= $this->confirm('Ambiente [yes producao|no para Sandbox]') ? 'Moip' : 'Sandbox';
38
		$token 		= $this->ask('token '.$environment);
39
		$key 		= $this->secret('Key '.$environment);
40
		$moip = Moip::first();
41
		$moip->environment = $environment === 'Moip' ? 1 : 0;
42
		$moip->token 	= $token;
43
		$moip->key 		= $key;
44
		$moip->save();	
45
	}
46
}
47