Completed
Push — master ( 3d4baf...9cf8b6 )
by Ricardo
05:18
created

ImportFromToken::__construct()   A

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\Jira\Jira;
12
use Integrations\Connectors\Gitlab\Gitlab;
13
use Log;
14
use Operador\Contracts\ActionInterface;
15
16
use Finder\Actions\Action as ActionBase;
17
18
class ImportFromToken extends ActionBase implements ActionInterface
19
{
20
    const CODE = 'importIntegrationToken';
21
    CONST MODEL = \Integrations\Models\Token::class;
22
    const TYPE = \Finder\Actions\Action::ROUTINE;
23
    
24
    protected $token = false;
25
26
    public function __construct(Token $token)
27
    {
28
        $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...
29
    }
30
31
    public function execute()
32
    {
33
        if (!$this->token->account || !$this->token->account->status) {
34
            dd($this->token);
35
            return false;
36
        }
37
        Log::channel('sitec-finder')->info('Tratando Token .. '.print_r($this->token, true));
38
39
        if ($this->token->account->integration_id == Sentry::getCodeForPrimaryKey()) {
40
            // (new \Integrations\Connectors\Sentry\Import($this->token))->bundle();
41
        } else if ($this->token->account->integration_id == Jira::getCodeForPrimaryKey()) {
42
            // (new \Integrations\Connectors\Jira\Import($this->token))->bundle();
43
        } else if ($this->token->account->integration_id == Gitlab::getCodeForPrimaryKey()) {
44
            (new \Integrations\Connectors\Gitlab\Import($this->token))->bundle();
45
        }
46
47
        return true;
48
    }
49
}
50