Skip to content

Commit 9f4f342

Browse files
committed
Set notifications and devices limit as constants
1 parent a32a268 commit 9f4f342

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/Devices.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
class Devices
88
{
9+
const DEVICES_LIMIT = 50;
10+
911
const IOS = 0;
1012
const ANDROID = 1;
1113
const AMAZON = 2;
@@ -48,11 +50,11 @@ public function getOne($id)
4850
*
4951
* @return array
5052
*/
51-
public function getAll($limit = 50, $offset = 0)
53+
public function getAll($limit = self::DEVICES_LIMIT, $offset = 0)
5254
{
5355
return $this->api->request('GET', '/players?' . http_build_query([
54-
'limit' => max(0, min(50, filter_var($limit, FILTER_VALIDATE_INT))),
55-
'offset' => max(0, min(50, filter_var($offset, FILTER_VALIDATE_INT))),
56+
'limit' => max(0, min(self::DEVICES_LIMIT, filter_var($limit, FILTER_VALIDATE_INT))),
57+
'offset' => max(0, min(self::DEVICES_LIMIT, filter_var($offset, FILTER_VALIDATE_INT))),
5658
]), [
5759
'headers' => [
5860
'Authorization' => 'Basic ' . $this->api->getConfig()->getApplicationAuthKey(),

src/Notifications.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
class Notifications
99
{
10+
const NOTIFICATIONS_LIMIT = 50;
11+
1012
/**
1113
* @var OneSignal
1214
*/
@@ -47,16 +49,16 @@ public function getOne($id)
4749
*
4850
* Application authentication key and ID must be set.
4951
*
50-
* @param int $limit How many notifications to return (max 50)
52+
* @param int $limit How many notifications to return (max 50)
5153
* @param int $offset Results offset (results are sorted by ID)
5254
*
5355
* @return array
5456
*/
55-
public function getAll($limit = 50, $offset = 0)
57+
public function getAll($limit = self::NOTIFICATIONS_LIMIT, $offset = 0)
5658
{
5759
return $this->api->request('GET', '/notifications?' . http_build_query([
58-
'limit' => max(0, min(50, filter_var($limit, FILTER_VALIDATE_INT))),
59-
'offset' => max(0, min(50, filter_var($offset, FILTER_VALIDATE_INT))),
60+
'limit' => max(0, min(self::NOTIFICATIONS_LIMIT, filter_var($limit, FILTER_VALIDATE_INT))),
61+
'offset' => max(0, min(self::NOTIFICATIONS_LIMIT, filter_var($offset, FILTER_VALIDATE_INT))),
6062
]), [
6163
'headers' => [
6264
'Authorization' => 'Basic ' . $this->api->getConfig()->getApplicationAuthKey(),

0 commit comments

Comments
 (0)