Completed
Push — master ( 0a2d54...99fa2d )
by
unknown
02:12
created

App   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 70
ccs 31
cts 31
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A appDetails() 0 19 1
A GetAppList() 0 13 1
A convertToObjects() 0 8 1
A convertGames() 0 12 3
1
<?php
2
3
namespace Syntax\SteamApi\Steam;
4
5
use Syntax\SteamApi\Client;
6
use Illuminate\Support\Collection;
7
use Syntax\SteamApi\Containers\App as AppContainer;
8
9
class App extends Client
10
{
11 2
    public function __construct()
12
    {
13 2
        parent::__construct();
14 2
        $this->url       = 'http://store.steampowered.com/';
15 2
        $this->interface = 'api';
16 2
    }
17
18 1
    public function appDetails($appIds, $country = null, $language = null)
19
    {
20
        // Set up the api details
21 1
        $this->method  = 'appdetails';
22 1
        $this->version = null;
23
24
        // Set up the arguments
25
        $arguments = [
26 1
            'appids' => $appIds,
27 1
            'cc' => $country,
28 1
            'l' => $language,
29
        ];
30
31
        // Get the client
32 1
        $client = $this->setUpClient($arguments);
33 1
        $apps   = $this->convertToObjects($client);
34
35 1
        return $apps;
36
    }
37
38 1
    public function GetAppList()
39
    {
40
        // Set up the api details
41 1
        $this->url       = 'http://api.steampowered.com/';
42 1
        $this->interface = 'ISteamApps';
43 1
        $this->method    = __FUNCTION__;
44 1
        $this->version   = 'v0001';
45
46
        // Get the client
47 1
        $client = $this->setUpClient();
48
49 1
        return $client->applist->apps->app;
50
    }
51
52 1
    protected function convertToObjects($apps)
53
    {
54 1
        $convertedApps = $this->convertGames($apps);
55
56 1
        $apps = $this->sortObjects($convertedApps);
57
58 1
        return $apps;
59
    }
60
61
    /**
62
     * @param $apps
63
     *
64
     * @return Collection
65
     */
66 1
    protected function convertGames($apps)
67
    {
68 1
        $convertedApps = new Collection();
69
70 1
        foreach ($apps as $app) {
71 1
            if (isset($app->data)) {
72 1
                $convertedApps->add(new AppContainer($app->data));
73
            }
74
        }
75
76 1
        return $convertedApps;
77
    }
78
}
79