forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatsTransformer.php
More file actions
38 lines (34 loc) · 1.03 KB
/
StatsTransformer.php
File metadata and controls
38 lines (34 loc) · 1.03 KB
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
<?php
namespace Pterodactyl\Transformers\Api\Client;
use Illuminate\Support\Arr;
class StatsTransformer extends BaseClientTransformer
{
/**
* @return string
*/
public function getResourceName(): string
{
return 'stats';
}
/**
* Transform stats from the daemon into a result set that can be used in
* the client API.
*
* @param array $data
* @return array
*/
public function transform(array $data)
{
return [
'current_state' => Arr::get($data, 'state', 'stopped'),
'is_suspended' => Arr::get($data, 'suspended', false),
'resources' => [
'memory_bytes' => Arr::get($data, 'memory_bytes', 0),
'cpu_absolute' => Arr::get($data, 'cpu_absolute', 0),
'disk_bytes' => Arr::get($data, 'disk_bytes', 0),
'network_rx_bytes' => Arr::get($data, 'network.rx_bytes', 0),
'network_tx_bytes' => Arr::get($data, 'network.tx_bytes', 0),
],
];
}
}