StartAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 18 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
13
class StartAction extends BaseGameAction implements GameActionInterface
14
{
15
    public function run($message, $user)
16
    {
17
        /** @var Game $game */
18
        $game = $this->gameService->findGame($message);
19
20
        if ($game->status == 0) {
21
            $game->status = 1;
22
            $question = $this->gameService->getRandomQuestion();
23
            $game->lastQuestion = $question->getId();
24
            $game->lastQuestionTime = new \DateTime('-1 hour');
25
            $this->gameService->em->persist($game);
26
            $this->gameService->em->flush();
27
            $this->botApi->sendMessage($message['chat']['id'], 'The game has started!');
28
            $this->gameService->askQuestion($game, $question);
0 ignored issues
show
Unused Code introduced by
The call to GameService::askQuestion() has too many arguments starting with $question.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
29
        } else {
30
            $this->botApi->sendMessage($message['chat']['id'], 'The game is already running...');
31
        }
32
    }
33
}
34