Completed
Push — 1.0 ( 58b1df...94433e )
by David
11:24
created

ZohoCopyDatabaseCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
4
namespace Wabel\Zoho\CRM\Copy;
5
6
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Wabel\Zoho\CRM\AbstractZohoDao;
11
12
class ZohoCopyDatabaseCommand extends Command
13
{
14
    /**
15
     * The list of Zoho DAOs to copy
16
     *
17
     * @var AbstractZohoDao[]
18
     */
19
    private $zohoDaos;
20
21
    /**
22
     * @var ZohoDatabaseCopier
23
     */
24
    private $zohoDatabaseCopier;
25
26
    /**
27
     * @param ZohoDatabaseCopier $zohoDatabaseCopier
28
     * @param \Wabel\Zoho\CRM\AbstractZohoDao[] $zohoDaos The list of Zoho DAOs to copy
29
     */
30
    public function __construct(ZohoDatabaseCopier $zohoDatabaseCopier, array $zohoDaos)
31
    {
32
        $this->zohoDatabaseCopier = $zohoDatabaseCopier;
33
        $this->zohoDaos = $zohoDaos;
34
    }
35
36
    protected function configure()
37
    {
38
        $this
39
            ->setName('zoho:copy-db')
40
            ->setDescription('Copies the Zoho database in local DB tables');
41
    }
42
43
    protected function execute(InputInterface $input, OutputInterface $output)
44
    {
45
        $output->writeln("Starting copying Zoho data into local database.");
46
        foreach ($this->zohoDaos as $zohoDao) {
47
            $output->writeln(sprintf("Copying data using <info>%s</info>", get_class($zohoDao)));
48
            $this->zohoDatabaseCopier->copy($zohoDao);
49
        }
50
        $output->writeln("Zoho data successfully copied.");
51
    }
52
}
53