Passed
Push[email protected] ( 356814...3dff17 )
by Bruno
20:21 queued 18:30
created

DeleteWebhook::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 7
rs 10
1
<?php
2
/**
3
 * Copyright © Wirecard Brasil. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See COPYING.txt for license details.
7
 */
8
9
declare(strict_types=1);
10
11
namespace Moip\Magento2\Console\Command\Preference;
12
13
use Magento\Framework\App\State;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\App\State was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Moip\Magento2\Model\Console\Command\Preference\Delete;
15
use Symfony\Component\Console\Command\Command;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Command\Command was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Symfony\Component\Console\Input\InputArgument;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Input\InputArgument was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Symfony\Component\Console\Input\InputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Input\InputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Symfony\Component\Console\Output\OutputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Output\OutputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
20
class DeleteWebhook extends Command
21
{
22
    const WEBHOOK_ID = 'id';
23
24
    /**
25
     * Delete.
26
     *
27
     * @var Moip\Magento2\Model\Console\Command\Preference\Delete
0 ignored issues
show
Bug introduced by
The type Moip\Magento2\Console\Co...mmand\Preference\Delete was not found. Did you mean Moip\Magento2\Model\Cons...mmand\Preference\Delete? If so, make sure to prefix the type with \.
Loading history...
28
     */
29
    protected $delete;
30
31
    /**
32
     * State.
33
     *
34
     * @var \Magento\Framework\App\State
35
     */
36
    protected $state;
37
38
    /**
39
     * DeleteWebhook constructor.
40
     *
41
     * @param State  $state
42
     * @param Delete $delete
43
     */
44
    public function __construct(
45
        State $state,
46
        Delete $delete
47
    ) {
48
        $this->state = $state;
49
        $this->delete = $delete;
0 ignored issues
show
Documentation Bug introduced by
It seems like $delete of type Moip\Magento2\Model\Cons...mmand\Preference\Delete is incompatible with the declared type Moip\Magento2\Console\Co...mmand\Preference\Delete of property $delete.

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...
50
        parent::__construct();
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    protected function execute(
57
        InputInterface $input,
58
        OutputInterface $output
59
    ) {
60
        $this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
0 ignored issues
show
Bug introduced by
The type Magento\Framework\App\Area was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
61
        $this->delete->setOutput($output);
62
63
        $ids[] = $input->getArgument(self::WEBHOOK_ID);
0 ignored issues
show
Comprehensibility Best Practice introduced by
$ids was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ids = array(); before regardless.
Loading history...
64
        $this->delete->delete($ids);
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    protected function configure()
71
    {
72
        $this->setName('moip:webhooks:delete_preference');
73
        $this->setDescription('Manually delete the preferred url for Webhooks');
74
        $this->setDefinition(
75
            [new InputArgument(self::WEBHOOK_ID, InputArgument::REQUIRED, 'ID Webhook - NPR-xxxx')]
76
        );
77
        parent::configure();
78
    }
79
}
80