SendCustomersCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
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\AbstractCustomerCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class SendCustomersCommand
11
 *
12
 * @category  Richdynamix
13
 * @package   PersonalisedProducts
14
 * @author    Steven Richardson ([email protected]) @mage_gizmo
15
 */
16 View Code Duplication
class SendCustomersCommand extends AbstractCustomerCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    /**
19
     * Configure the console command's name and description
20
     */
21
    protected function configure()
22
    {
23
        $this->setName('pio:send:customers');
24
        $this->setDescription('Send all customers to the PredictionIO event server');
25
        parent::configure();
26
    }
27
28
    /**
29
     * Execute the command
30
     *
31
     * @param InputInterface $input
32
     * @param OutputInterface $output
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $collection = $this->_getCustomerCollection();
37
        $output->writeln('Preparing to send '. count($collection) .' customers');
38
39
        try {
40
            $sentCount = $this->_sendCustomerData($collection);
41
            $output->writeln('Successfully sent '. $sentCount .' customers to the PredictionIO event server');
42
        } catch (\Exception $e) {
43
            $output->writeln('Error: ' . $e->getMessage());
44
        }
45
    }
46
}
47