Create   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 16
c 1
b 0
f 0
dl 0
loc 60
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 9 1
A __construct() 0 7 1
A configure() 0 8 1
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\Synchronize;
12
13
use Getnet\SubSellerMagento\Model\Console\Command\Synchronize\Create as ModelCreate;
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
/**
21
 * Create sub seller with Getnet.
22
 */
23
class Create extends Command
24
{
25
    /**
26
     * @const string.
27
     */
28
    public const SUB_SELLER_ID = 'sub_seller_id';
29
30
    /**
31
     * @var ModelCreate
32
     */
33
    protected $create;
34
35
    /**
36
     * @var State
37
     */
38
    protected $state;
39
40
    /**
41
     * @param State       $state
42
     * @param ModelCreate $create
43
     */
44
    public function __construct(
45
        State $state,
46
        ModelCreate $create
47
    ) {
48
        $this->state = $state;
49
        $this->create = $create;
50
        parent::__construct();
51
    }
52
53
    /**
54
     * Execute.
55
     *
56
     * @param InputInterface  $input
57
     * @param OutputInterface $output
58
     */
59
    protected function execute(
60
        InputInterface $input,
61
        OutputInterface $output
62
    ) {
63
        $this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
64
        $this->create->setOutput($output);
65
66
        $subSellerId = (int) $input->getArgument(self::SUB_SELLER_ID);
67
        $this->create->create($subSellerId);
68
    }
69
70
    /**
71
     * Configure.
72
     *
73
     * @return void
74
     */
75
    protected function configure()
76
    {
77
        $this->setName('getnet:sub_seller:create');
78
        $this->setDescription('Create Sub Seller on Getnet');
79
        $this->setDefinition(
80
            [new InputArgument(self::SUB_SELLER_ID, InputArgument::REQUIRED, 'Seller Id')]
81
        );
82
        parent::configure();
83
    }
84
}
85