Completed
Pull Request — master (#5)
by Daniel
05:19
created

RunFeedReaderCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 45
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 7 1
A __construct() 0 5 1
A configure() 0 7 1
1
<?php
2
3
namespace Jellyfish\Feed\Command;
4
5
use Jellyfish\Feed\FeedReaderManagerInterface;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class RunFeedReaderCommand extends Command
12
{
13
    public const NAME = 'feed:feed-reader:run';
14
    public const DESCRIPTION = 'Run feed reader.';
15
16
    /**
17
     * @var \Jellyfish\Feed\FeedReaderManagerInterface
18
     */
19
    protected $feedReaderManager;
20
21
    /**
22
     * @param \Jellyfish\Feed\FeedReaderManagerInterface $feedReaderManager
23
     */
24
    public function __construct(FeedReaderManagerInterface $feedReaderManager)
25
    {
26
        parent::__construct(null);
27
28
        $this->feedReaderManager = $feedReaderManager;
29
    }
30
31
    /**
32
     * @return void
33
     */
34
    protected function configure(): void
35
    {
36
        parent::configure();
37
38
        $this->setName(static::NAME);
39
        $this->setDescription(static::DESCRIPTION);
40
        $this->addArgument('identifier', InputArgument::REQUIRED, 'Feed reader identifier.');
41
    }
42
43
    /**
44
     * @param \Symfony\Component\Console\Input\InputInterface $input
45
     * @param \Symfony\Component\Console\Output\OutputInterface $output
46
     *
47
     * @return int|null
48
     */
49
    protected function execute(InputInterface $input, OutputInterface $output): ?int
50
    {
51
        $identifier = (string) $input->getArgument('identifier');
52
53
        $this->feedReaderManager->readFromFeedReader($identifier);
54
55
        return null;
56
    }
57
}
58