Completed
Pull Request — master (#37)
by Mahmoud
08:04
created

App   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 51.61%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 68
ccs 16
cts 31
cp 0.5161
rs 10

5 Methods

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