SendMessage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 5 1
A configure() 0 5 1
A getMessageSender() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zored\TelegramBundle\Console;
6
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Zored\TelegramBundle\Telegram\Command\MessageSender;
11
12
class SendMessage extends AbstractConsoleCommand
13
{
14
    protected static $defaultName = 'tg:client:message';
15
16
    /**
17
     * {@inheritdoc}
18
     */
19
    protected function configure()
20
    {
21
        $this->addArgument('peer', InputArgument::REQUIRED, 'Chat or user name from your dialog list.');
22
        $this->addArgument('message', InputArgument::REQUIRED, 'Message to send in Markdown format.');
23
        $this->setDescription('Send message to user or chat.');
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected function execute(InputInterface $input, OutputInterface $output)
30
    {
31
        $this->getMessageSender()->send(
32
            $input->getArgument('peer'),
33
            $input->getArgument('message')
34
        );
35
    }
36
37
    protected function getMessageSender(): MessageSender
38
    {
39
        return $this->getContainer()->get(MessageSender::class);
40
    }
41
}
42