SendOrdersCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 2
nc 3
nop 2
1
<?php
2
3
namespace Richdynamix\PersonalisedProducts\Console\Command;
4
5
use \Richdynamix\PersonalisedProducts\Console\Command\AbstractOrdersCommand;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use \Symfony\Component\Config\Definition\Exception\Exception;
11
12
/**
13
 * Class SendOrdersCommand
14
 *
15
 * @category  Richdynamix
16
 * @package   PersonalisedProducts
17
 * @author    Steven Richardson ([email protected]) @mage_gizmo
18
 */
19
class SendOrdersCommand extends AbstractOrdersCommand
20
{
21
    /**
22
     * Configure the console command's name and description
23
     */
24
    protected function configure()
25
    {
26
        $this->setName('pio:send:orders');
27
        $this->setDescription('Send all customer-buy-products actions to the PredictionIO event server');
28
        parent::configure();
29
    }
30
31
    /**
32
     * Execute the command
33
     *
34
     * @param InputInterface $input
35
     * @param OutputInterface $output
36
     */
37
    protected function execute(InputInterface $input, OutputInterface $output)
38
    {
39
        $customerProducts = $this->_getCustomerProductCollection($this->_getOrderCollection());
40
        $output->writeln('Preparing to send '. count($customerProducts) .' orders');
41
        $output->writeln(
42
            'Preparing ' . $this->_getCustomerCount() . ' customers with a total of ' .
43
            $this->_getProductCount() . ' products'
44
        );
45
46
        try {
47
            $sentCount = $this->_sendCustomerBuyProductData($customerProducts);
48
            $output->writeln(
49
                'Successfully set a total of ' . $this->_getProductCount()
50
                . ' product purchases to ' . $this->_getCustomerCount() . ' customers' .
51
                ' on a total of ' . $sentCount . ' orders'
52
            );
53
        } catch (Exception $e) {
0 ignored issues
show
Bug introduced by
The class Symfony\Component\Config...ion\Exception\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
54
            $output->writeln('Error: ' . $e->getMessage());
55
        }
56
    }
57
}
58