Games::listTopGames()   B
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 27
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 27
ccs 0
cts 24
cp 0
rs 8.5806
cc 4
eloc 19
nc 2
nop 1
crap 20
1
<?php
2
namespace Redbox\Twitch\Resource;
3
use Redbox\Twitch;
4
5
class Games extends ResourceAbstract {
6
7
    public function listTopGames($args = array())
8
    {
9
        $response = $this->call('listTopGames', $args);
10
11
        $games = [];
12
13
        if (is_object($response) === true && isset($response->top) === true)
14
        {
15
            foreach($response->top as $topgame) {
16
                $game = new Game();
17
                $game->setName($topgame->game->name);
18
                $game->setViewers($topgame->viewers);
19
                $game->setChannels($topgame->channels);
20
                $game->setBoxLarge($topgame->game->box->large);
21
                $game->setBoxMedium($topgame->game->box->medium);
22
                $game->setBoxSmall($topgame->game->box->small);
23
                $game->setBoxTemplate($topgame->game->box->template);
24
                $game->setLogoLarge($topgame->game->logo->large);
25
                $game->setLogoMedium($topgame->game->logo->medium);
26
                $game->setLogoSmall($topgame->game->logo->small);
27
                $game->setLogoTemplate($topgame->game->logo->template);
28
                $games[] = $game;
29
            }
30
        }
31
32
        return $games;
33
    }
34
}