Group   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 29
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A GetGroupSummary() 0 26 2
1
<?php
2
3
namespace Syntax\SteamApi\Steam;
4
5
use Syntax\SteamApi\Client;
6
use Syntax\SteamApi\Containers\Group as GroupContainer;
7
8
class Group extends Client
9
{
10 2
    public function GetGroupSummary($group)
11
    {
12
        // Set up the api details
13 2
        $this->method = 'memberslistxml';
14
15 2
        if (is_numeric($group)) {
16 1
            $this->url = 'http://steamcommunity.com/gid/';
17
        } else {
18 1
            $this->url = 'http://steamcommunity.com/groups/';
19
        }
20
21 2
        $this->url = $this->url . $group;
22
23
        // Set up the arguments
24
        $arguments = [
25 2
            'xml' => 1,
26
        ];
27
28
        // Get the client
29 2
        $client = $this->setUpXml($arguments);
30
31
        // Clean up the games
32 2
        $group = new GroupContainer($client);
0 ignored issues
show
Bug introduced by
It seems like $client defined by $this->setUpXml($arguments) on line 29 can be null; however, Syntax\SteamApi\Containers\Group::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
33
34 2
        return $group;
35
    }
36
}
37