StartAction::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 13
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
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