GamesAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 17 3
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 GamesAction extends BaseGameAction implements GameActionInterface
14
{
15
    public function run($message, $user)
16
    {
17
        $games = $this->gameService->getActiveGames();
18
19
        $text = 'Current active games: '."\n";
20
21
        /** @var Game $game */
22
        foreach ($games as $game) {
23
            $text .= '- '.$game->title."\n";
24
        }
25
26
        if (count($games) == 0) {
27
            $text .= '- No active games, sorry. Invite me into group, and press /start';
28
        }
29
30
        $this->botApi->sendMessage($message['chat']['id'], $text);
31
    }
32
}
33