Skip to content

Commit 2cc60db

Browse files
committed
- minor changes to apply consistent formatting/case
1 parent 3e99b7b commit 2cc60db

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

API_REFERENCE.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,26 @@ Sets the name for a specific client.
167167

168168
### List Active Clients
169169
```php
170-
public function list_active_clients(bool $includeTrafficUsage = true, bool $includeUnifiDevices = true): array
170+
public function list_active_clients(bool $include_traffic_usage = true, bool $include_unifi_devices = true): array
171171
```
172172
Lists all currently active clients.
173173

174174
**Parameters:**
175-
- `$includeTrafficUsage` (bool): Whether to include traffic usage information (default: true)
176-
- `$includeUnifiDevices` (bool): Whether to include UniFi devices (default: true)
175+
- `$include_traffic_usage` (bool): Whether to include traffic usage information (default: true)
176+
- `$include_unifi_devices` (bool): Whether to include UniFi devices (default: true)
177177

178178
**Returns:** array - Array of active client objects
179179

180180
### List Client History
181181
```php
182-
public function list_clients_history(bool $onlyNonBlocked = true, bool $includeUnifiDevices = true, int $withinHours = 0): array
182+
public function list_clients_history(bool $only_non_blocked = true, bool $include_unifi_devices = true, int $within_hours = 0): array
183183
```
184184
Lists historical client information.
185185

186186
**Parameters:**
187-
- `$onlyNonBlocked` (bool): Whether to only show non-blocked clients (default: true)
188-
- `$includeUnifiDevices` (bool): Whether to include UniFi devices (default: true)
189-
- `$withinHours` (int): Hours of history to retrieve (default: 0)
187+
- `$only_non_blocked` (bool): Whether to only show non-blocked clients (default: true)
188+
- `$include_unifi_devices` (bool): Whether to include UniFi devices (default: true)
189+
- `$within_hours` (int): Hours of history to retrieve (default: 0)
190190

191191
**Returns:** array - Array of historical client objects
192192

src/Client.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use UniFi_API\Exceptions\LoginFailedException;
1515
use UniFi_API\Exceptions\LoginRequiredException;
1616
use UniFi_API\Exceptions\MethodDeprecatedException;
17-
use UniFi_API\Exceptions\NotAnOsConsoleException;
17+
use UniFi_API\Exceptions\NotAUnifiOsConsoleException;
1818

1919
/**
2020
* The UniFi API client class.
@@ -34,7 +34,7 @@
3434
class Client
3535
{
3636
/** Constants. */
37-
const CLASS_VERSION = '2.0.3';
37+
const CLASS_VERSION = '2.0.5';
3838
const CURL_METHODS_ALLOWED = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
3939
const DEFAULT_CURL_METHOD = 'GET';
4040

@@ -85,7 +85,7 @@ class Client
8585
*
8686
* @param string $user username to use when connecting to the UniFi controller
8787
* @param string $password password to use when connecting to the UniFi controller
88-
* @param string $baseurl base URL of the UniFi controller which *must* include an 'https://' prefix,
88+
* @param string $baseurl base URL of the UniFi controller which *must* include a 'https://' prefix,
8989
* a port suffix (e.g. :8443) is required for non-UniFi OS controllers,
9090
* do not add trailing slashes, defaults to 'https://127.0.0.1:8443'
9191
* @param string|null $site short site name to access, defaults to 'default'
@@ -302,8 +302,8 @@ public function logout(): bool
302302
* @param int|null $up optional, upload speed limit in kbps
303303
* @param int|null $down optional, download speed limit in kbps
304304
* @param int|null $megabytes optional, data transfer limit in MB
305-
* @param string|null $ap_mac optional, AP MAC address to which client is connected, should result in faster
306-
* authorization for the client device
305+
* @param string|null $ap_mac optional, AP MAC address to which the client is connected
306+
* (should result in faster authorization for the client device)
307307
* @return bool true upon success
308308
* @throws Exception
309309
*/
@@ -725,8 +725,8 @@ public function stat_monthly_aps(?int $start = null, ?int $end = null, ?string $
725725
* - only supported with UniFi controller versions 5.8.X and higher
726726
* - make sure that the retention policy for 5-minute stats is set to the correct value in
727727
* the controller settings
728-
* - make sure that "Clients Historical Data" has been enabled in the UniFi controller settings in the Maintenance
729-
* section
728+
* - make sure that the "Clients Historical Data" option has been enabled in the UniFi controller settings in
729+
* the Maintenance section
730730
* @param string|null $mac optional, MAC address of the user/client device to return stats for
731731
* @param int|null $start optional, Unix timestamp in milliseconds
732732
* @param int|null $end optional, Unix timestamp in milliseconds
@@ -1095,16 +1095,16 @@ public function list_clients(?string $mac = null)
10951095
/**
10961096
* Fetch active client devices
10971097
*
1098-
* @param bool $includeTrafficUsage include the traffic usage of the client devices in the response
1099-
* @param bool $includeUnifiDevices include UniFi devices in the response
1098+
* @param bool $include_traffic_usage include the traffic usage of the client devices in the response
1099+
* @param bool $include_unifi_devices include UniFi devices in the response
11001100
* @return array|bool returns an array of active client device objects, false upon error
11011101
* @throws Exception
11021102
*/
1103-
public function list_active_clients(bool $includeTrafficUsage = true, bool $includeUnifiDevices = true)
1103+
public function list_active_clients(bool $include_traffic_usage = true, bool $include_unifi_devices = true)
11041104
{
11051105
$query = http_build_query([
1106-
'includeTrafficUsage' => $includeTrafficUsage,
1107-
'includeUnifiDevices' => $includeUnifiDevices,
1106+
'include_traffic_usage' => $include_traffic_usage,
1107+
'include_unifi_devices' => $include_unifi_devices,
11081108
]);
11091109

11101110
return $this->fetch_results('/v2/api/site/' . $this->site . '/clients/active?' . $query);
@@ -1113,19 +1113,19 @@ public function list_active_clients(bool $includeTrafficUsage = true, bool $incl
11131113
/**
11141114
* Fetch client devices history (offline client devices)
11151115
*
1116-
* @param bool $onlyNonBlocked include non-blocked client devices in the response
1117-
* @param bool $includeUnifiDevices include UniFi devices in the response
1118-
* @param int $withinHours the number of hours a device has been offline to be included in the response
1116+
* @param bool $only_non_blocked include non-blocked client devices in the response
1117+
* @param bool $include_unifi_devices include UniFi devices in the response
1118+
* @param int $within_hours the number of hours a device has been offline to be included in the response
11191119
* (0 = no limit)
11201120
* @return array|bool returns an array of (offline) client device objects, false upon error
11211121
* @throws Exception
11221122
*/
1123-
public function list_clients_history(bool $onlyNonBlocked = true, bool $includeUnifiDevices = true, int $withinHours = 0)
1123+
public function list_clients_history(bool $only_non_blocked = true, bool $include_unifi_devices = true, int $within_hours = 0)
11241124
{
11251125
$query = http_build_query([
1126-
'onlyNonBlocked' => $onlyNonBlocked,
1127-
'includeUnifiDevices' => $includeUnifiDevices,
1128-
'withinHours' => $withinHours,
1126+
'only_non_blocked' => $only_non_blocked,
1127+
'include_unifi_devices' => $include_unifi_devices,
1128+
'within_hours' => $within_hours,
11291129
]);
11301130

11311131
return $this->fetch_results('/v2/api/site/' . $this->site . '/clients/history?' . $query);
@@ -3268,7 +3268,7 @@ public function check_controller_update()
32683268
public function get_update_os_console()
32693269
{
32703270
if (!$this->is_unifi_os) {
3271-
throw new NotAnOsConsoleException();
3271+
throw new NotAUnifiOsConsoleException();
32723272
}
32733273

32743274
return $this->fetch_results('/api/firmware/update', null, false, true, false);
@@ -3284,7 +3284,7 @@ public function get_update_os_console()
32843284
public function update_os_console(): bool
32853285
{
32863286
if (!$this->is_unifi_os) {
3287-
throw new NotAnOsConsoleException();
3287+
throw new NotAUnifiOsConsoleException();
32883288
}
32893289

32903290
$payload = ['persistFullData' => true];
@@ -4453,7 +4453,7 @@ protected function create_x_csrf_token_header()
44534453
/**
44544454
* Callback function for cURL to extract and store cookies as needed.
44554455
*
4456-
* @param object|resource $ch the cURL instance (type hinting is unavailable for cURL resources)
4456+
* @param object|resource|false $ch the cURL instance (type hinting is unavailable for cURL resources)
44574457
* @param string $header_line the response header line number
44584458
* @return int length of the header line
44594459
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace UniFi_API\Exceptions;
4+
5+
use Exception;
6+
7+
class NotAUnifiOsConsoleException extends Exception
8+
{
9+
public function __construct()
10+
{
11+
parent::__construct('This is not a UniFi OS console.');
12+
}
13+
}

src/Exceptions/NotAnOsConsoleException.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)