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

StopAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 18 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