forked from waylaidwanderer/PHP-SteamCommunity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.php
54 lines (45 loc) · 1.08 KB
/
User.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Created by PhpStorm.
* User: Joel
* Date: 2016-02-18
* Time: 4:48 PM
*/
namespace waylaidwanderer\SteamCommunity;
use waylaidwanderer\SteamCommunity\User\Group;
class User
{
const BASE_URL = "http://steamcommunity.com/profiles/";
private $steamId;
private $profile;
public function __construct($steamId)
{
$this->steamId = $steamId;
}
public function getProfileXml()
{
if ($this->profile == null) {
$url = self::BASE_URL . $this->steamId . '/?xml=1';
$xml = Helper::cURL($url);
$this->profile = new \SimpleXMLElement($xml);
}
return $this->profile;
}
public function getPersonaName()
{
$profile = $this->getProfileXml();
return (string)$profile->steamID;
}
/**
* @return Group[]
*/
public function getGroups()
{
$groups = [];
$profile = $this->getProfileXml();
foreach ($profile->groups->group as $groupXml) {
$groups[] = new Group($groupXml);
}
return $groups;
}
}