1 | <?php |
||
7 | trait SteamId |
||
8 | { |
||
9 | public $formatted; |
||
10 | |||
11 | private $rawValue; |
||
12 | |||
13 | private static $ID32 = 'id32'; |
||
14 | |||
15 | private static $ID64 = 'id64'; |
||
16 | |||
17 | private static $ID3 = 'id3'; |
||
18 | |||
19 | private static $id64Base = '76561197960265728'; |
||
20 | |||
21 | /** |
||
22 | * @param string|int $id |
||
23 | * @param string|null $format |
||
24 | * |
||
25 | * @return mixed |
||
26 | */ |
||
27 | 8 | public function convertId($id, $format = null) |
|
28 | { |
||
29 | 8 | $this->convertToAll($id); |
|
30 | |||
31 | switch ($format) { |
||
32 | 8 | case 'ID32': |
|
33 | 8 | case 'id32': |
|
34 | 8 | case 32: |
|
35 | return $this->formatted->{self::$ID32}; |
||
36 | 8 | case 'ID64': |
|
37 | 8 | case 'id64': |
|
38 | 8 | case 64: |
|
39 | return $this->formatted->{self::$ID64}; |
||
40 | 8 | case 'ID3': |
|
41 | 8 | case 'id3': |
|
42 | 8 | case 3: |
|
43 | return $this->formatted->{self::$ID3}; |
||
44 | default: |
||
45 | 8 | return $this->formatted; |
|
46 | } |
||
47 | } |
||
48 | |||
49 | 47 | protected function setUpFormatted() |
|
56 | |||
57 | 30 | private function convertToAll($id) |
|
70 | |||
71 | 30 | private function convertToID32() |
|
79 | |||
80 | 30 | private function convertToID64() |
|
85 | |||
86 | 30 | private function convertToID3() |
|
91 | |||
92 | 30 | private function determineIDType($id) |
|
108 | |||
109 | /** |
||
110 | * Get a raw value from any type of steam id |
||
111 | * |
||
112 | * @param $id |
||
113 | * @param $type |
||
114 | * @param $matches |
||
115 | */ |
||
116 | 30 | private function getRawValue($id, $type, $matches) |
|
140 | |||
141 | } |
||
142 |