ImportFromToken::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * 
4
 */
5
6
namespace Fabrica\Tasks;
7
8
use Fabrica\Tools\Databases\Mysql\Mysql as MysqlTool;
9
use Integrations\Models\Token;
10
use Integrations\Connectors\Sentry\Sentry;
11
use Integrations\Connectors\Sentry\Import as SentryImport;
12
use Integrations\Connectors\Jira\Jira;
13
use Integrations\Connectors\Jira\Import as JiraImport;
14
use Integrations\Connectors\Gitlab\Gitlab;
15
use Integrations\Connectors\Gitlab\Import as GitlabImport;
16
use Log;
17
use Operador\Contracts\ActionInterface;
18
19
use Operador\Actions\Action as ActionBase;
20
21
class ImportFromToken extends ActionBase implements ActionInterface
22
{
23
    const CODE = 'importIntegrationToken';
24
    CONST MODEL = \Integrations\Models\Token::class;
25
    const TYPE = \Operador\Actions\Action::ROUTINE;
26
    
27
    protected $token = false;
28
29
    public function __construct(Token $token)
30
    {
31
        $this->token = $token;
0 ignored issues
show
Documentation Bug introduced by
It seems like $token of type object<Integrations\Models\Token> is incompatible with the declared type boolean of property $token.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
32
    }
33
34
    public function execute()
35
    {
36
        if (!$this->token->account || !$this->token->account->status) {
37
            $this->notice('Token ignorado sem account .. '.print_r($this->token, true));
38
            return false;
39
        }
40
        $this->info('Tratando Token de Integração: '.$this->token->account->integration_id);
41
42
        if ($this->token->account->integration_id == Sentry::getCodeForPrimaryKey()) {
43
            SentryImport::makeWithOutput($this->output, $this->token)->handle();
44
        } else if ($this->token->account->integration_id == Jira::getCodeForPrimaryKey()) {
45
            JiraImport::makeWithOutput($this->output, $this->token)->handle();
46
        } else if ($this->token->account->integration_id == Gitlab::getCodeForPrimaryKey()) {
47
            GitlabImport::makeWithOutput($this->output, $this->token)->handle();
48
        }
49
50
        return true;
51
    }
52
}
53