UpdateFeed   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 14 1
A execute() 0 11 2
1
<?php
2
/**
3
 * ownCloud - News
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Bernhard Posselt <[email protected]>
9
 * @copyright Bernhard Posselt 2016
10
 */
11
12
namespace OCA\News\Command\Updater;
13
14
use Exception;
15
16
use Symfony\Component\Console\Command\Command;
17
use Symfony\Component\Console\Input\InputArgument;
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Output\OutputInterface;
20
21
use OCA\News\Service\FeedService;
22
23
24
class UpdateFeed extends Command {
25
    private $feedService;
26
27
    public function __construct(FeedService $feedService) {
28
        parent::__construct();
29
        $this->feedService = $feedService;
30
    }
31
32
    protected function configure() {
33
        $this->setName('news:updater:update-feed')
34
            ->addArgument(
35
                'feed-id',
36
                InputArgument::REQUIRED,
37
                'feed id, integer'
38
            )
39
            ->addArgument(
40
                'user-id',
41
                InputArgument::REQUIRED,
42
                'user id of a user, string'
43
            )
44
            ->setDescription('Console API for updating a single user\'s feed');
45
    }
46
47
    protected function execute(InputInterface $input, OutputInterface $output) {
48
        $feedId = $input->getArgument('feed-id');
49
        $userId = $input->getArgument('user-id');
50
        try {
51
            $this->feedService->update($feedId, $userId);
52
        } catch (Exception $e) {
53
            $output->writeln('<error>Could not update feed with id ' . $feedId .
54
                             ' and user ' . $userId . ': ' . $e->getMessage() .
55
                             '</error> ');
56
        }
57
    }
58
59
}
60