NotificationCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
/**
3
 * Command to send report (best use with cron).
4
 */
5
6
namespace PiedWeb\ConversationBundle\Command;
7
8
use PiedWeb\ConversationBundle\Service\NewMessageMailNotifier;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class NotificationCommand extends Command
14
{
15
    /**
16
     * @var NewMessageMailNotifier
17
     */
18
    protected $notifier;
19
20
    public function __construct(
21
        NewMessageMailNotifier $notifier
22
    ) {
23
        $this->notifier = $notifier;
24
        parent::__construct();
25
    }
26
27
    protected function configure()
28
    {
29
        $this
30
            ->setName('conversation:notify')
31
            ->setDescription('Send a report of last messages.')
32
        ;
33
    }
34
35
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        if (true === $this->notifier->send()) {
38
            $output->writeln('Notification sent with success.');
39
40
            return 0;
41
        }
42
43
        $output->writeln('No new message.');
44
    }
45
}
46