Documentation

PushoverHandler extends SocketHandler
in package

Sends notifications through the pushover api to mobile phones

Tags
author

Sebastian Göttschkes sebastian.goettschkes@googlemail.com

see
https://www.pushover.net/api

Table of Contents

Properties

$bubble  : bool
$formatter  : FormatterInterface|null
$level  : Level
$processors  : array<string|int, callable>
$emergencyLevel  : Level
$expire  : int
$highPriorityLevel  : Level
$parameterNames  : array<string, bool>
All parameters that can be sent to Pushover
$retry  : int
$sounds  : array<string|int, string>
Sounds the api supports by default
$title  : string
$token  : string
$useFormattedMessage  : bool
$user  : string|int|null
$users  : array<string|int, int|string>

Methods

__construct()  : mixed
__destruct()  : mixed
__sleep()  : mixed
close()  : void
We will not close a PersistentSocket instance so it can be reused in other requests.
closeSocket()  : void
Close socket, if open
getBubble()  : bool
Gets the bubbling behavior.
getChunkSize()  : int|null
Get current chunk size
getConnectionString()  : string
Get current connection string
getConnectionTimeout()  : float
Get current connection timeout setting
getFormatter()  : FormatterInterface
getLevel()  : Level
Gets minimum logging level at which this handler will be triggered.
getTimeout()  : float
Get current in-transfer timeout
getWritingTimeout()  : float
Get current local writing timeout
handle()  : bool
Handles a record.
handleBatch()  : void
Handles a set of records at once.
isConnected()  : bool
Check to see if the socket is currently available.
isHandling()  : bool
Checks whether the given record will be handled by this handler.
isPersistent()  : bool
Get persistent setting
popProcessor()  : callable
pushProcessor()  : HandlerInterface
reset()  : void
setBubble()  : $this
Sets the bubbling behavior.
setChunkSize()  : $this
Set chunk size. Only has effect during connection in the writing cycle.
setConnectionTimeout()  : $this
Set connection timeout. Only has effect before we connect.
setEmergencyLevel()  : $this
setFormatter()  : HandlerInterface
setHighPriorityLevel()  : $this
setLevel()  : $this
Sets minimum logging level at which this handler will be triggered.
setPersistent()  : $this
Set socket connection to be persistent. It only has effect before the connection is initiated.
setTimeout()  : $this
Set write timeout. Only has effect before we connect.
setWritingTimeout()  : $this
Set writing timeout. Only has effect during connection in the writing cycle.
useFormattedMessage()  : $this
Use the formatted message?
fsockopen()  : resource|false
Wrapper to allow mocking
fwrite()  : int|false
Wrapper to allow mocking
generateDataStream()  : string
getDefaultFormatter()  : FormatterInterface
Gets the default formatter.
getResource()  : resource|null
pfsockopen()  : resource|false
Wrapper to allow mocking
processRecord()  : LogRecord
resetProcessors()  : void
streamGetMetadata()  : array<string|int, mixed>|bool
Wrapper to allow mocking
streamSetChunkSize()  : int|false
Wrapper to allow mocking
streamSetTimeout()  : bool
Wrapper to allow mocking
write()  : void
Connect (if necessary) and write to the socket
buildContent()  : string
buildHeader()  : string

Properties

$processors

protected array<string|int, callable> $processors = []
Tags
phpstan-var

array<(callable(LogRecord): LogRecord)|ProcessorInterface>

$parameterNames

All parameters that can be sent to Pushover

private array<string, bool> $parameterNames = ['token' => true, 'user' => true, 'message' => true, 'device' => true, 'title' => true, 'url' => true, 'url_title' => true, 'priority' => true, 'timestamp' => true, 'sound' => true, 'retry' => true, 'expire' => true, 'callback' => true]
Tags
see
https://pushover.net/api

$sounds

Sounds the api supports by default

private array<string|int, string> $sounds = ['pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming', 'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb', 'persistent', 'echo', 'updown', 'none']
Tags
see
https://pushover.net/api#sounds

Methods

__construct()

public __construct(string $token, string|array<string|int, mixed> $users[, string|null $title = null ][, int|string|Level $level = Level::Critical ][, bool $bubble = true ][, bool $useSSL = true ][, int|string|Level|LogLevel::* $highPriorityLevel = Level::Critical ][, int|string|Level|LogLevel::* $emergencyLevel = Level::Emergency ][, int $retry = 30 ][, int $expire = 25200 ][, bool $persistent = false ][, float $timeout = 0.0 ][, float $writingTimeout = 10.0 ][, float|null $connectionTimeout = null ][, int|null $chunkSize = null ]) : mixed
Parameters
$token : string

Pushover api token

$users : string|array<string|int, mixed>

Pushover user id or array of ids the message will be sent to

$title : string|null = null

Title sent to the Pushover API

$level : int|string|Level = Level::Critical

The minimum logging level at which this handler will be triggered

$bubble : bool = true

Whether the messages that are handled can bubble up the stack or not

$useSSL : bool = true

Whether to connect via SSL. Required when pushing messages to users that are not the pushover.net app owner. OpenSSL is required for this option.

$highPriorityLevel : int|string|Level|LogLevel::* = Level::Critical

The minimum logging level at which this handler will start sending "high priority" requests to the Pushover API

$emergencyLevel : int|string|Level|LogLevel::* = Level::Emergency

The minimum logging level at which this handler will start sending "emergency" requests to the Pushover API

$retry : int = 30

The retry parameter specifies how often (in seconds) the Pushover servers will send the same notification to the user.

$expire : int = 25200

The expire parameter specifies how many seconds your notification will continue to be retried for (every retry seconds).

$persistent : bool = false

Flag to enable/disable persistent connections

$timeout : float = 0.0

Socket timeout to wait until the request is being aborted

$writingTimeout : float = 10.0

Socket timeout to wait until the request should've been sent/written

$connectionTimeout : float|null = null

Socket connect timeout to wait until the connection should've been established

$chunkSize : int|null = null

Sets the chunk size. Only has effect during connection in the writing cycle

Tags
phpstan-param

string|array<int|string> $users

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::* $highPriorityLevel

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::* $emergencyLevel

__destruct()

public __destruct() : mixed

close()

We will not close a PersistentSocket instance so it can be reused in other requests.

public close() : void

closeSocket()

Close socket, if open

public closeSocket() : void

getBubble()

Gets the bubbling behavior.

public getBubble() : bool
Return values
bool —

true means that this handler allows bubbling. false means that bubbling is not permitted.

getChunkSize()

Get current chunk size

public getChunkSize() : int|null
Return values
int|null

getConnectionString()

Get current connection string

public getConnectionString() : string
Return values
string

getConnectionTimeout()

Get current connection timeout setting

public getConnectionTimeout() : float
Return values
float

getLevel()

Gets minimum logging level at which this handler will be triggered.

public getLevel() : Level
Return values
Level

getTimeout()

Get current in-transfer timeout

public getTimeout() : float
Return values
float

getWritingTimeout()

Get current local writing timeout

public getWritingTimeout() : float
Return values
float

handle()

Handles a record.

public handle(LogRecord $record) : bool
Parameters
$record : LogRecord

The record to handle

Tags
inheritDoc
Return values
bool —

true means that this handler handled the record, and that bubbling is not permitted. false means the record was either not processed or that this handler allows bubbling.

handleBatch()

Handles a set of records at once.

public handleBatch(array<string|int, mixed> $records) : void
Parameters
$records : array<string|int, mixed>

The records to handle

Tags
inheritDoc

isConnected()

Check to see if the socket is currently available.

public isConnected() : bool

UDP might appear to be connected but might fail when writing. See http://php.net/fsockopen for details.

Return values
bool

isHandling()

Checks whether the given record will be handled by this handler.

public isHandling(LogRecord $record) : bool
Parameters
$record : LogRecord

Partial log record having only a level initialized

Tags
inheritDoc
Return values
bool

isPersistent()

Get persistent setting

public isPersistent() : bool
Return values
bool

setBubble()

Sets the bubbling behavior.

public setBubble(bool $bubble) : $this
Parameters
$bubble : bool

true means that this handler allows bubbling. false means that bubbling is not permitted.

Return values
$this

setChunkSize()

Set chunk size. Only has effect during connection in the writing cycle.

public setChunkSize(int $bytes) : $this
Parameters
$bytes : int
Return values
$this

setEmergencyLevel()

public setEmergencyLevel(int|string|Level|LogLevel::* $level) : $this
Parameters
$level : int|string|Level|LogLevel::*
Tags
phpstan-param

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::* $level

Return values
$this

setHighPriorityLevel()

public setHighPriorityLevel(int|string|Level|LogLevel::* $level) : $this
Parameters
$level : int|string|Level|LogLevel::*
Tags
phpstan-param

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::* $level

Return values
$this

setLevel()

Sets minimum logging level at which this handler will be triggered.

public setLevel(Level|LogLevel::* $level) : $this
Parameters
$level : Level|LogLevel::*

Level or level name

Tags
phpstan-param

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::* $level

Return values
$this

setPersistent()

Set socket connection to be persistent. It only has effect before the connection is initiated.

public setPersistent(bool $persistent) : $this
Parameters
$persistent : bool
Return values
$this

setWritingTimeout()

Set writing timeout. Only has effect during connection in the writing cycle.

public setWritingTimeout(float $seconds) : $this
Parameters
$seconds : float

0 for no timeout

Return values
$this

useFormattedMessage()

Use the formatted message?

public useFormattedMessage(bool $useFormattedMessage) : $this
Parameters
$useFormattedMessage : bool
Return values
$this

fsockopen()

Wrapper to allow mocking

protected fsockopen() : resource|false
Return values
resource|false

fwrite()

Wrapper to allow mocking

protected fwrite(string $data) : int|false
Parameters
$data : string
Return values
int|false

getResource()

protected getResource() : resource|null
Return values
resource|null

pfsockopen()

Wrapper to allow mocking

protected pfsockopen() : resource|false
Return values
resource|false

streamGetMetadata()

Wrapper to allow mocking

protected streamGetMetadata() : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|bool

buildHeader()

private buildHeader(string $content) : string
Parameters
$content : string
Return values
string
On this page

Search results