-
-
Notifications
You must be signed in to change notification settings - Fork 191
/
Copy pathPowerMonitor.php
39 lines (30 loc) · 1.19 KB
/
PowerMonitor.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
<?php
namespace Native\Laravel;
use Native\Laravel\Client\Client;
use Native\Laravel\Contracts\PowerMonitor as PowerMonitorContract;
use Native\Laravel\Enums\SystemIdleStatesEnum;
use Native\Laravel\Enums\ThermalStatesEnum;
class PowerMonitor implements PowerMonitorContract
{
public function __construct(protected Client $client) {}
public function getSystemIdleState(int $threshold): SystemIdleStatesEnum
{
$result = $this->client->get('power-monitor/get-system-idle-state', [
'threshold' => $threshold,
])->json('result');
return SystemIdleStatesEnum::tryFrom($result) ?? SystemIdleStatesEnum::UNKNOWN;
}
public function getSystemIdleTime(): int
{
return $this->client->get('power-monitor/get-system-idle-time')->json('result');
}
public function getCurrentThermalState(): ThermalStatesEnum
{
$result = $this->client->get('power-monitor/get-current-thermal-state')->json('result');
return ThermalStatesEnum::tryFrom($result) ?? ThermalStatesEnum::UNKNOWN;
}
public function isOnBatteryPower(): bool
{
return $this->client->get('power-monitor/is-on-battery-power')->json('result');
}
}