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.

SyncAllCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 42
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 2 Features 1
Metric Value
cc 2
eloc 31
c 2
b 2
f 1
nc 2
nop 2
dl 0
loc 42
rs 9.424
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\SyliusMailchimpPlugin\Command;
6
7
use Symfony\Component\Console\Input\ArrayInput;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Symfony\Component\Console\Style\SymfonyStyle;
12
13
final class SyncAllCommand extends BaseSyncCommand
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    protected function configure(): void
19
    {
20
        $this
21
            ->setName('odiseo:mailchimp:sync-all')
22
            ->setDescription('Synchronize all data to Mailchimp.')
23
            ->addOption('create-only', 'c', InputOption::VALUE_NONE, 'With this option the existing content will be not updated.')
24
            ->addOption('purge', 'p', InputOption::VALUE_NONE, 'Reset all the content and reload from scratch.')
25
        ;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output): int
32
    {
33
        $withPurge = $input->getOption('purge');
34
        $createOnly = $input->getOption('create-only');
35
36
        $this->io = new SymfonyStyle($input, $output);
37
38
        $this->io->title('Synchronizing all data to Mailchimp');
39
40
        $application = $this->getApplication();
41
42
        if ($application) {
43
            $syncStoresCommand = $application->find('odiseo:mailchimp:sync-stores');
44
            $syncCustomersCommand = $application->find('odiseo:mailchimp:sync-customers');
45
            $syncProductsCommand = $application->find('odiseo:mailchimp:sync-products');
46
            $syncCartsCommand = $application->find('odiseo:mailchimp:sync-carts');
47
            $syncOrdersCommand = $application->find('odiseo:mailchimp:sync-orders');
48
49
            $syncStoresCommand->run(new ArrayInput([
50
                '--isSyncing' => true,
51
                '--purge' => $withPurge,
52
            ]), $output);
53
54
            $syncCustomersCommand->run(new ArrayInput([
55
                '--create-only' => $createOnly,
56
            ]), $output);
57
            $syncProductsCommand->run(new ArrayInput([
58
                '--create-only' => $createOnly,
59
            ]), $output);
60
            $syncCartsCommand->run(new ArrayInput([
61
                '--create-only' => $createOnly,
62
            ]), $output);
63
            $syncOrdersCommand->run(new ArrayInput([
64
                '--create-only' => $createOnly,
65
            ]), $output);
66
67
            $syncStoresCommand->run(new ArrayInput([
68
                '--isSyncing' => false,
69
            ]), $output);
70
        }
71
72
        return 0;
73
    }
74
}
75