GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( f51f95...468920 )
by Andreas
03:39
created

ExportAbandonedCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 3
dl 0
loc 7
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaign\Console\Command;
7
8
use CommerceLeague\ActiveCampaign\Helper\AbandonedCart as AbandonedCartHelper;
9
use CommerceLeague\ActiveCampaign\MessageQueue\Topics;
10
use Magento\Framework\Console\Cli;
11
use Magento\Framework\MessageQueue\PublisherInterface;
12
use Symfony\Component\Console\Helper\ProgressBarFactory;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Consol...lper\ProgressBarFactory 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...
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
16
/**
17
 * Class ExportAbandonedCommand
18
 */
19
class ExportAbandonedCommand extends AbstractExportCommand
20
{
21
    private const NAME = 'activecampaign:export:abandoned-cart';
22
23
    /**
24
     * @var AbandonedCartHelper
25
     */
26
    private $abandonedCartHelper;
27
28
    /**
29
     * @param AbandonedCartHelper $abandonedCartHelper
30
     * @param ProgressBarFactory $progressBarFactory
31
     * @param PublisherInterface $publisher
32
     */
33
    public function __construct(
34
        AbandonedCartHelper $abandonedCartHelper,
35
        ProgressBarFactory $progressBarFactory,
36
        PublisherInterface $publisher
37
    ) {
38
        $this->abandonedCartHelper = $abandonedCartHelper;
39
        parent::__construct($progressBarFactory, $publisher);
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45
    protected function configure()
46
    {
47
        $this->setName(self::NAME);
48
    }
49
50
    /**
51
     * @param InputInterface $input
52
     * @param OutputInterface $output
53
     * @return int|void|null
54
     * @throws \Exception
55
     */
56
    protected function execute(InputInterface $input, OutputInterface $output)
57
    {
58
        $quoteIds = $this->abandonedCartHelper->getExportCollection()->getAllIds();
59
60
        $progressBar = $this->createProgressBar(
61
            $output,
62
            count($quoteIds),
63
            'Export Abandoned Cart(s)'
64
        );
65
66
        foreach ($quoteIds as $quoteId) {
67
            $this->publisher->publish(
68
                Topics::QUOTE_ABANDONED_CART_EXPORT,
69
                json_encode(['quote_id' => $quoteId])
0 ignored issues
show
Bug introduced by
json_encode(array('quote_id' => $quoteId)) of type string is incompatible with the type array|object expected by parameter $data of Magento\Framework\Messag...herInterface::publish(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

69
                /** @scrutinizer ignore-type */ json_encode(['quote_id' => $quoteId])
Loading history...
70
            );
71
72
            $progressBar->advance();
73
        }
74
75
        $output->writeln('');
76
        $output->writeln(sprintf(
77
                '<info>Exported %s abandoned cart(s)</info>',
78
                (count($quoteIds)))
79
        );
80
81
        return Cli::RETURN_SUCCESS;
82
    }
83
}
84