Skip to content

Commit

Permalink
CS-Fixer: Check Example folder
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark committed Aug 28, 2024
1 parent bdbdd2e commit 42091d0
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 82 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
->append([
__DIR__.'/.php-cs-fixer.dist.php',
])
->in('Example')
->in('src')
->in('tests');

Expand Down
26 changes: 14 additions & 12 deletions Example/CompleteNotificationExample.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

/*
declare(strict_types=1);

/**
* This file is part of the Pushover package.
*
* (c) Serhiy Lunak <https://github.com/slunak>
Expand Down Expand Up @@ -28,20 +30,20 @@
*/
class CompleteNotificationExample
{
public function completeNotification()
public function completeNotification(): void
{
// instantiate pushover application and recipient of the notification (can be injected into service using Dependency Injection)
$application = new Application("replace_with_pushover_application_api_token");
$recipient = new Recipient("replace_with_pushover_user_key");
$application = new Application('replace_with_pushover_application_api_token');
$recipient = new Recipient('replace_with_pushover_user_key');

// if required, specify devices, otherwise notification will be sent to all devices
$recipient->addDevice("android");
$recipient->addDevice("iphone");
$recipient->addDevice('android');
$recipient->addDevice('iphone');

// compose a message
$message = new Message("This is a test message", "This is a title of the message");
$message->setUrl("https://www.example.com");
$message->setUrlTitle("Example URL");
$message = new Message('This is a test message', 'This is a title of the message');
$message->setUrl('https://www.example.com');
$message->setUrlTitle('Example URL');
$message->setisHtml(false);
$message->setTimestamp(new \DateTime('now'));
$message->setTtl(60 * 60 * 24); // 1 day
Expand All @@ -53,17 +55,17 @@ public function completeNotification()
// set notification built-in sound
$notification->setSound(new Sound(Sound::PUSHOVER));
// or set notification custom sound
$notification->setCustomSound(new CustomSound("door_open"));
$notification->setCustomSound(new CustomSound('door_open'));
// add attachment
$notification->setAttachment(new Attachment("/path/to/file.jpg", Attachment::MIME_TYPE_JPEG));
$notification->setAttachment(new Attachment('/path/to/file.jpg', Attachment::MIME_TYPE_JPEG));

// push notification
/** @var MessageResponse $response */
$response = $notification->push();

// work with response object
if ($response->isSuccessful()) {
//...
// ...
}
}
}
14 changes: 8 additions & 6 deletions Example/EmergencyNotificationExample.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

/*
declare(strict_types=1);

/**
* This file is part of the Pushover package.
*
* (c) Serhiy Lunak <https://github.com/slunak>
Expand All @@ -25,14 +27,14 @@
*/
class EmergencyNotificationExample
{
public function sendEmergencyNotification()
public function sendEmergencyNotification(): void
{
// instantiate pushover application and recipient of the notification (can be injected into service using Dependency Injection)
$application = new Application("replace_with_pushover_application_api_token");
$recipient = new Recipient("replace_with_pushover_user_key");
$application = new Application('replace_with_pushover_application_api_token');
$recipient = new Recipient('replace_with_pushover_user_key');

// compose a message
$message = new Message("This is a test message", "Simple Notification");
$message = new Message('This is a test message', 'Simple Notification');
// set priority by creating new Priority object with priority value, retry and expire parameters.
// Retry and expire parameters required only with emergency priority
// See https://pushover.net/api#priority for details.
Expand All @@ -47,7 +49,7 @@ public function sendEmergencyNotification()

// work with response object
if ($response->isSuccessful()) {
//...
// ...
}
}
}
22 changes: 12 additions & 10 deletions Example/GlancesExample.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

/*
declare(strict_types=1);

/**
* This file is part of the Pushover package.
*
* (c) Serhiy Lunak <https://github.com/slunak>
Expand All @@ -22,21 +24,20 @@
*/
class GlancesExample
{
public function glancesExample()
public function glancesExample(): void
{
// instantiate pushover application and recipient (can be injected into service using Dependency Injection)
$application = new Application("replace_with_pushover_application_api_token");
$recipient = new Recipient("replace_with_pushover_user_key");
$application = new Application('replace_with_pushover_application_api_token');
$recipient = new Recipient('replace_with_pushover_user_key');

// create glance data fields
$glanceDataFields = new GlanceDataFields();
$glanceDataFields
->setTitle("Title")
->setText("Text")
->setSubtext("Subtext")
->setTitle('Title')
->setText('Text')
->setSubtext('Subtext')
->setCount(1)
->setPercent(99)
;
->setPercent(99);

// instantiate glance
$glance = new Glance($application, $glanceDataFields);
Expand All @@ -49,7 +50,8 @@ public function glancesExample()
$response = $glance->push();

// or loop over recipients
$recipients = array(); // array of Recipient objects
$recipients = []; // array of Recipient objects

foreach ($recipients as $recipient) {
$glance->setRecipient($recipient);
$response = $glance->push();
Expand Down
22 changes: 12 additions & 10 deletions Example/GroupsExample.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

/*
declare(strict_types=1);

/**
* This file is part of the Pushover package.
*
* (c) Serhiy Lunak <https://github.com/slunak>
Expand Down Expand Up @@ -28,35 +30,35 @@
*/
class GroupsExample
{
public function groupsExample()
public function groupsExample(): void
{
// instantiate pushover application and recipient (can be injected into service using Dependency Injection)
$application = new Application("replace_with_pushover_application_api_token");
$recipient = new Recipient("replace_with_pushover_user_key");
$application = new Application('replace_with_pushover_application_api_token');
$recipient = new Recipient('replace_with_pushover_user_key');

// instantiate pushover group (can be injected into service using Dependency Injection)
$group = new Group("replace_with_pushover_group_key", $application);
$group = new Group('replace_with_pushover_group_key', $application);

// Use any valid key or placeholder ^[a-zA-Z0-9]{30}$ as group key to create new group
$createGroupResponse = $group->create('Test');
$newGroupKey = $createGroupResponse->getGroupKey();

// Obtain list of all groups
$listGroupsResponse = $group->list();
/** @var array<string, string> $groups ['name' => 'key', 'name2' => 'key2'] */
$groups = $listGroupsResponse->getGroups();

// Retrieve information about the group from the API and populate the object with it.
/** @var RetrieveGroupResponse $retrieveGroupResponse */
$retrieveGroupResponse = $group->retrieveGroupInformation();

// rename the group
/** @var RenameGroupResponse $renameGroupResponse */
$renameGroupResponse = $group->rename("Rename Group Test");
$renameGroupResponse = $group->rename('Rename Group Test');

// add user to the group
$recipient->setMemo("This is a test memo"); // optional
$recipient->addDevice("android"); // optional
$recipient->setMemo('This is a test memo'); // optional
$recipient->addDevice('android'); // optional
/** @var AddUserToGroupResponse $addUserToGroupResponse */
$addUserToGroupResponse = $group->addUser($recipient);

Expand Down
14 changes: 8 additions & 6 deletions Example/HtmlNotificationExample.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

/*
declare(strict_types=1);

/**
* This file is part of the Pushover package.
*
* (c) Serhiy Lunak <https://github.com/slunak>
Expand All @@ -24,14 +26,14 @@
*/
class HtmlNotificationExample
{
public function sendHtmlNotification()
public function sendHtmlNotification(): void
{
// instantiate pushover application and recipient of the notification (can be injected into service using Dependency Injection)
$application = new Application("replace_with_pushover_application_api_token");
$recipient = new Recipient("replace_with_pushover_user_key");
$application = new Application('replace_with_pushover_application_api_token');
$recipient = new Recipient('replace_with_pushover_user_key');

// compose a message
$message = new Message("This is <b>example</b> of <u>HTML</u> styled <i>message</i>.", "HTML Notification");
$message = new Message('This is <b>example</b> of <u>HTML</u> styled <i>message</i>.', 'HTML Notification');
// set message to html, see https://pushover.net/api#html for details
$message->setIsHtml(true);

Expand All @@ -44,7 +46,7 @@ public function sendHtmlNotification()

// work with response object
if ($response->isSuccessful()) {
//...
// ...
}
}
}
13 changes: 8 additions & 5 deletions Example/LicensingExample.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

/*
declare(strict_types=1);

/**
* This file is part of the Pushover package.
*
* (c) Serhiy Lunak <https://github.com/slunak>
Expand All @@ -21,11 +23,11 @@
*/
class LicensingExample
{
public function licensingExample()
public function licensingExample(): void
{
// instantiate pushover application and recipient (can be injected into service using Dependency Injection)
$application = new Application("replace_with_pushover_application_api_token");
$recipient = new Recipient("replace_with_pushover_user_key");
$application = new Application('replace_with_pushover_application_api_token');
$recipient = new Recipient('replace_with_pushover_user_key');

// create license
$license = new License($application);
Expand All @@ -50,7 +52,8 @@ public function licensingExample()
$response = $license->assign();

// or loop over recipients or emails
$recipients = array(); // array of Recipient objects
$recipients = []; // array of Recipient objects

foreach ($recipients as $recipient) {
$license->setRecipient($recipient);
$response = $license->assign();
Expand Down
17 changes: 9 additions & 8 deletions Example/ReceiptExample.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

/*
declare(strict_types=1);

/**
* This file is part of the Pushover package.
*
* (c) Serhiy Lunak <https://github.com/slunak>
Expand All @@ -12,7 +14,6 @@
namespace Serhiy\Pushover\Example;

use Serhiy\Pushover\Api\Receipts\Receipt;

use Serhiy\Pushover\Application;
use Serhiy\Pushover\Client\Response\CancelRetryResponse;
use Serhiy\Pushover\Client\Response\ReceiptResponse;
Expand All @@ -23,15 +24,15 @@
*/
class ReceiptExample
{
public function queryEmergencyNotificationReceiptExample()
public function queryEmergencyNotificationReceiptExample(): void
{
// instantiate pushover application and receipt (can be injected into service using Dependency Injection)
$application = new Application("replace_with_pushover_application_api_token");
$application = new Application('replace_with_pushover_application_api_token');
$receipt = new Receipt($application);

// query emergency notification receipt
/** @var ReceiptResponse $response */
$response = $receipt->query("replace_with_receipt");
$response = $receipt->query('replace_with_receipt');

// work with response
if ($response->isSuccessful()) {
Expand Down Expand Up @@ -64,15 +65,15 @@ public function queryEmergencyNotificationReceiptExample()
}
}

public function cancelEmergencyNotificationRetryExample()
public function cancelEmergencyNotificationRetryExample(): void
{
// instantiate pushover application and receipt (can be injected into service using Dependency Injection)
$application = new Application("replace_with_pushover_application_api_token");
$application = new Application('replace_with_pushover_application_api_token');
$receipt = new Receipt($application);

// cancel emergency notification retry
/** @var CancelRetryResponse $response */
$response = $receipt->cancelRetry("replace_with_receipt");
$response = $receipt->cancelRetry('replace_with_receipt');

// work with response
if ($response->isSuccessful()) {
Expand Down
14 changes: 8 additions & 6 deletions Example/ResponseExample.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

/*
declare(strict_types=1);

/**
* This file is part of the Pushover package.
*
* (c) Serhiy Lunak <https://github.com/slunak>
Expand All @@ -25,21 +27,21 @@
*/
class ResponseExample
{
public function responseExample()
public function responseExample(): void
{
// instantiate pushover application and recipient of the notification (can be injected into service using Dependency Injection)
$application = new Application("replace_with_pushover_application_api_token");
$recipient = new Recipient("replace_with_pushover_user_key");
$application = new Application('replace_with_pushover_application_api_token');
$recipient = new Recipient('replace_with_pushover_user_key');

// compose a message
$message = new Message("This is a test message", "Simple Notification");
$message = new Message('This is a test message', 'Simple Notification');

// create notification
$notification = new Notification($application, $recipient, $message);

// push notification
/**
* Response object
* Response object.
*
* @var MessageResponse $response
*/
Expand Down
Loading

0 comments on commit 42091d0

Please sign in to comment.