MoipAuthCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 4
c 5
b 0
f 0
lcom 0
cbo 0
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fire() 0 11 3
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