UpdateEsRatesCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 30
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 5 1
A execute() 0 15 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