digiaonline / notification-wrapper
A super-basic wrapper for notifications/messages
Installs: 41 750
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
- ext-json: *
Requires (Dev)
- phpstan/phpstan: ^0.10.6
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2023-03-12 21:34:40 UTC
README
A super-basic wrapper for notifications/messages
Installation
composer require digiaonline/notification-wrapper
Usage
// Create a notification $notification = new Notification('TYPE_FOO', ['id' => 1, 'name' => 'John']); // Encode it as JSON (now you can send it somewhere) $json = \json_encode($notification); // Decode the notification on the other end $notification = Notification::fromJson($json); var_dump($notification->getType() === 'TYPE_FOO'); // true var_dump($notification->getPayload() === ['id' => 1, 'name' => 'John']); // true
License
MIT