RemindCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A configure() 0 5 1
A execute() 0 11 2
1
<?php
2
3
namespace HappyHourReminder\Command;
4
5
use HappyHourReminder\Adapter\AdapterInterface;
6
use HappyHourReminder\Client\ClientInterface;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Class RemindCommand
13
 *
14
 * @package HappyHourReminder\Command
15
 */
16
class RemindCommand extends Command
17
{
18
    /** @var AdapterInterface */
19
    protected $adapter;
20
    
21
    /** @var ClientInterface */
22
    protected $client;
23
24
    /**
25
     * CheckCommand constructor.
26
     *
27
     * @param AdapterInterface $adapter
28
     * @param ClientInterface  $client
29
     */
30
    public function __construct(AdapterInterface $adapter, ClientInterface $client)
31
    {
32
        $this->adapter = $adapter;
33
        $this->client  = $client;
34
35
        parent::__construct();
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    protected function configure()
42
    {
43
        $this->setName('remind');
44
        $this->setDescription('Checks if happy hour is available and reminds about it.');
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52
        $output->writeln('Checking for happyhour...');
53
54
        $response = $this->client->getResponse();
55
56
        if ($response->isAvailable()) {
57
            $output->writeln('Happyhour available.');
58
            $this->adapter->remind($response);
59
        }
60
    }
61
}
62