Completed
Push — master ( cefc6c...96cc5a )
by Kirill
03:32
created

StartAction::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: chrl
5
 * Date: 27/10/16
6
 * Time: 11:08
7
 */
8
9
namespace Chrl\AppBundle\GameAction;
10
11
use Chrl\AppBundle\Entity\Game;
12
use Chrl\AppBundle\Entity\Question;
13
14
class StartAction extends BaseGameAction implements GameActionInterface
15
{
16
    public function run($message, $user)
17
    {
18
		/** @var Game $game */
19
        $game = $this->gameService->findGame($message);
20
21
        if ($game->status == 0) {
22
			$game->status = 1;
23
			$this->gameService->em->persist($game);
24
			$this->gameService->em->flush();
25
			$this->botApi->sendMessage($message['chat']['id'], 'The game has started!');
26
		} else {
27
			$this->botApi->sendMessage($message['chat']['id'], 'The game is already running...');
28
			$question = $this->gameService->getRandomQuestion();
0 ignored issues
show
Unused Code introduced by
$question is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
29
		}
30
    }
31
}
32