-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathCPU.php
More file actions
48 lines (41 loc) · 922 Bytes
/
CPU.php
File metadata and controls
48 lines (41 loc) · 922 Bytes
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
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\ServerInfo\Resources;
/**
* @psalm-api
*/
class CPU implements \JsonSerializable {
public function __construct(
private string $name,
private int $threads,
) {
}
public function getName(): string {
return $this->name;
}
public function getThreads(): int {
return $this->threads;
}
/**
* Retrieves the system load averages.
*
* @return array|false Returns an array containing the system load averages for the last 1, 5, and 15 minutes.
*/
public function getAverageLoad(): array|false {
if (function_exists('sys_getloadavg')) {
return sys_getloadavg();
}
return false;
}
#[\Override]
public function jsonSerialize(): array {
return [
'name' => $this->name,
'threads' => $this->threads,
];
}
}