UpdateEsRatesCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\CurrencyExchangeBundle\Command;
13
14
use GuzzleHttp\Exception\ClientException;
15
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * A command which store currency rates in ES.
21
 */
22
class UpdateEsRatesCommand extends ContainerAwareCommand
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    protected function configure()
28
    {
29
        $this->setName('ongr:currency:update')
30
            ->setDescription('Currency Update');
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function execute(InputInterface $input, OutputInterface $output)
37
    {
38
        try {
39
            $data = $this->getContainer()->get('ongr_currency_exchange.currency_rates_service');
40
            $data->reloadRates();
41
            $output->writeln(sprintf('<info>Currency rates updated</info>'));
42
        } catch (ClientException $e) {
43
            $output->writeln(
44
                sprintf(
45
                    '<error>Error ocurred during update. </error> <comment>`%s`</comment>',
46
                    $e->getMessage()
47
                )
48
            );
49
        }
50
    }
51
}
52