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

StartAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

1 Method

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