Completed
Push — master ( 34916a...e20ad5 )
by Kirill
02:25
created

StopAction::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 2
eloc 11
nc 2
nop 2
1
<?php
2
3
namespace Chrl\AppBundle\GameAction;
4
5
use Chrl\AppBundle\Entity\Game;
6
7
class StopAction extends BaseGameAction implements GameActionInterface
8
{
9
    public function run($message, $user)
10
    {
11
        /** @var Game $game */
12
        $game = $this->gameService->findGame($message);
13
14
        if ($game->status == 1) {
15
            $game->status = 0;
16
17
            $this->gameService->em->persist($game);
18
            $this->gameService->em->flush();
19
            $this->botApi->sendMessage($message['chat']['id'], 'The game has stopped!');
20
        } else {
21
            $this->botApi->sendMessage(
22
                $message['chat']['id'],
23
                'The game is not running...Use /start command to run game.'
24
            );
25
        }
26
    }
27
}
28