Token::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
9
declare(strict_types=1);
10
11
namespace Getnet\SubSellerMagento\Console\Command\Administrative;
12
13
use Getnet\SubSellerMagento\Model\Console\Command\Administrative\Token as ModelToken;
14
use Magento\Framework\App\State;
15
use Symfony\Component\Console\Command\Command;
16
use Symfony\Component\Console\Input\InputArgument;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
class Token extends Command
21
{
22
    /**
23
     * Store Id.
24
     */
25
    public const STORE_ID = 'store_id';
26
27
    /**
28
     * @var ModelToken
29
     */
30
    protected $token;
31
32
    /**
33
     * @var State
34
     */
35
    protected $state;
36
37
    /**
38
     * @param State      $state
39
     * @param ModelToken $token
40
     */
41
    public function __construct(
42
        State $state,
43
        ModelToken $token
44
    ) {
45
        $this->state = $state;
46
        $this->token = $token;
47
        parent::__construct();
48
    }
49
50
    /**
51
     * Execute.
52
     *
53
     * @param InputInterface  $input
54
     * @param OutputInterface $output
55
     */
56
    protected function execute(
57
        InputInterface $input,
58
        OutputInterface $output
59
    ) {
60
        $this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
61
        $this->token->setOutput($output);
62
63
        $storeId = $input->getArgument(self::STORE_ID);
64
        $this->token->newToken($storeId);
65
    }
66
67
    /**
68
     * Configure.
69
     *
70
     * @return void
71
     */
72
    protected function configure()
73
    {
74
        $this->setName('getnet:sub_seller:administrative_token');
75
        $this->setDescription('Generate Administrative Token Manually');
76
        $this->setDefinition(
77
            [new InputArgument(self::STORE_ID, InputArgument::OPTIONAL, 'Store Id')]
78
        );
79
        parent::configure();
80
    }
81
}
82