PushoverHandler
extends SocketHandler
in package
Sends notifications through the pushover api to mobile phones
Tags
Table of Contents
Properties
- $bubble : bool
- $formatter : FormatterInterface|null
- $level : int
- $processors : array<string|int, callable>
- $chunkSize : int|null
- $connectionString : string
- $connectionTimeout : float
- $emergencyLevel : int
- $errno : int|null
- $errstr : string|null
- $expire : int
- $highPriorityLevel : int
- $lastSentBytes : int|null
- $lastWritingAt : float|null
- $parameterNames : array<string, bool>
- All parameters that can be sent to Pushover
- $persistent : bool
- $resource : resource|null
- $retry : int
- $sounds : array<string|int, string>
- Sounds the api supports by default
- $timeout : float
- $title : string
- $token : string
- $useFormattedMessage : bool
- $user : string|int|null
- $users : array<string|int, int|string>
- $writingTimeout : float
Methods
- __construct() : mixed
- __destruct() : mixed
- __sleep() : mixed
- close() : void
- Closes the handler.
- 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
- {@inheritDoc}
- getLevel() : int
- 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
- {@inheritDoc}
- handleBatch() : void
- Handles a set of records at once.
- isConnected() : bool
- Check to see if the socket is currently available.
- isHandling() : bool
- {@inheritDoc}
- isPersistent() : bool
- Get persistent setting
- popProcessor() : callable
- {@inheritDoc}
- pushProcessor() : HandlerInterface
- {@inheritDoc}
- reset() : void
- setBubble() : self
- Sets the bubbling behavior.
- setChunkSize() : self
- Set chunk size. Only has effect during connection in the writing cycle.
- setConnectionTimeout() : self
- Set connection timeout. Only has effect before we connect.
- setEmergencyLevel() : self
- setFormatter() : HandlerInterface
- {@inheritDoc}
- setHighPriorityLevel() : self
- setLevel() : self
- Sets minimum logging level at which this handler will be triggered.
- setPersistent() : self
- Set socket connection to be persistent. It only has effect before the connection is initiated.
- setTimeout() : self
- Set write timeout. Only has effect before we connect.
- setWritingTimeout() : self
- Set writing timeout. Only has effect during connection in the writing cycle.
- useFormattedMessage() : self
- Use the formatted message?
- fsockopen() : resource|false
- Wrapper to allow mocking
- fwrite() : int|bool
- Wrapper to allow mocking
- generateDataStream() : string
- getDefaultFormatter() : FormatterInterface
- Gets the default formatter.
- getResource() : resource|null
- pfsockopen() : resource|false
- Wrapper to allow mocking
- processRecord() : array<string|int, mixed>
- Processes a record.
- resetProcessors() : void
- streamGetMetadata() : array<string|int, mixed>|bool
- Wrapper to allow mocking
- streamSetChunkSize() : int|bool
- Wrapper to allow mocking
- streamSetTimeout() : bool
- Wrapper to allow mocking
- write() : void
- Connect (if necessary) and write to the socket
- buildContent() : string
- buildHeader() : string
- connect() : void
- connectIfNotConnected() : void
- createSocketResource() : void
- setSocketTimeout() : void
- setStreamChunkSize() : void
- validateTimeout() : void
- writeToSocket() : void
- writingIsTimedOut() : bool
Properties
$bubble
protected
bool
$bubble
= true
$formatter
protected
FormatterInterface|null
$formatter
$level
protected
int
$level
= \Monolog\Logger::DEBUG
Tags
$processors
protected
array<string|int, callable>
$processors
= []
Tags
$chunkSize
private
int|null
$chunkSize
$connectionString
private
string
$connectionString
$connectionTimeout
private
float
$connectionTimeout
$emergencyLevel
private
int
$emergencyLevel
$errno
private
int|null
$errno
= null
$errstr
private
string|null
$errstr
= null
$expire
private
int
$expire
$highPriorityLevel
private
int
$highPriorityLevel
$lastSentBytes
private
int|null
$lastSentBytes
= null
$lastWritingAt
private
float|null
$lastWritingAt
= null
$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
$persistent
private
bool
$persistent
$resource
private
resource|null
$resource
$retry
private
int
$retry
$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
$timeout
private
float
$timeout
$title
private
string
$title
$token
private
string
$token
$useFormattedMessage
private
bool
$useFormattedMessage
= false
$user
private
string|int|null
$user
= null
$users
private
array<string|int, int|string>
$users
$writingTimeout
private
float
$writingTimeout
Methods
__construct()
public
__construct(string $token, string|array<string|int, mixed> $users[, string|null $title = null ][, mixed $level = Logger::CRITICAL ][, bool $bubble = true ][, bool $useSSL = true ][, string|int $highPriorityLevel = Logger::CRITICAL ][, string|int $emergencyLevel = Logger::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 : mixed = Logger::CRITICAL
- $bubble : bool = true
- $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 : string|int = Logger::CRITICAL
-
The minimum logging level at which this handler will start sending "high priority" requests to the Pushover API
- $emergencyLevel : string|int = Logger::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
__destruct()
public
__destruct() : mixed
__sleep()
public
__sleep() : mixed
close()
Closes the handler.
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|nullgetConnectionString()
Get current connection string
public
getConnectionString() : string
Return values
stringgetConnectionTimeout()
Get current connection timeout setting
public
getConnectionTimeout() : float
Return values
floatgetFormatter()
{@inheritDoc}
public
getFormatter() : FormatterInterface
Return values
FormatterInterfacegetLevel()
Gets minimum logging level at which this handler will be triggered.
public
getLevel() : int
Tags
Return values
intgetTimeout()
Get current in-transfer timeout
public
getTimeout() : float
Return values
floatgetWritingTimeout()
Get current local writing timeout
public
getWritingTimeout() : float
Return values
floathandle()
{@inheritDoc}
public
handle(array<string|int, mixed> $record) : bool
Parameters
- $record : array<string|int, mixed>
Return values
boolhandleBatch()
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 (an array of record arrays)
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
boolisHandling()
{@inheritDoc}
public
isHandling(array<string|int, mixed> $record) : bool
Parameters
- $record : array<string|int, mixed>
Return values
boolisPersistent()
Get persistent setting
public
isPersistent() : bool
Return values
boolpopProcessor()
{@inheritDoc}
public
popProcessor() : callable
Return values
callablepushProcessor()
{@inheritDoc}
public
pushProcessor(callable $callback) : HandlerInterface
Parameters
- $callback : callable
Return values
HandlerInterfacereset()
public
reset() : void
setBubble()
Sets the bubbling behavior.
public
setBubble(bool $bubble) : self
Parameters
- $bubble : bool
-
true means that this handler allows bubbling. false means that bubbling is not permitted.
Return values
selfsetChunkSize()
Set chunk size. Only has effect during connection in the writing cycle.
public
setChunkSize(int $bytes) : self
Parameters
- $bytes : int
Return values
selfsetConnectionTimeout()
Set connection timeout. Only has effect before we connect.
public
setConnectionTimeout(float $seconds) : self
Parameters
- $seconds : float
Tags
Return values
selfsetEmergencyLevel()
public
setEmergencyLevel(int|string $value) : self
Parameters
- $value : int|string
Tags
Return values
selfsetFormatter()
{@inheritDoc}
public
setFormatter(FormatterInterface $formatter) : HandlerInterface
Parameters
- $formatter : FormatterInterface
Return values
HandlerInterfacesetHighPriorityLevel()
public
setHighPriorityLevel(int|string $value) : self
Parameters
- $value : int|string
Tags
Return values
selfsetLevel()
Sets minimum logging level at which this handler will be triggered.
public
setLevel(Level|LevelName|LogLevel::* $level) : self
Parameters
- $level : Level|LevelName|LogLevel::*
-
Level or level name
Return values
selfsetPersistent()
Set socket connection to be persistent. It only has effect before the connection is initiated.
public
setPersistent(bool $persistent) : self
Parameters
- $persistent : bool
Return values
selfsetTimeout()
Set write timeout. Only has effect before we connect.
public
setTimeout(float $seconds) : self
Parameters
- $seconds : float
Tags
Return values
selfsetWritingTimeout()
Set writing timeout. Only has effect during connection in the writing cycle.
public
setWritingTimeout(float $seconds) : self
Parameters
- $seconds : float
-
0 for no timeout
Return values
selfuseFormattedMessage()
Use the formatted message?
public
useFormattedMessage(bool $value) : self
Parameters
- $value : bool
Return values
selffsockopen()
Wrapper to allow mocking
protected
fsockopen() : resource|false
Return values
resource|falsefwrite()
Wrapper to allow mocking
protected
fwrite(string $data) : int|bool
Parameters
- $data : string
Return values
int|boolgenerateDataStream()
protected
generateDataStream(array<string|int, mixed> $record) : string
Parameters
- $record : array<string|int, mixed>
Return values
stringgetDefaultFormatter()
Gets the default formatter.
protected
getDefaultFormatter() : FormatterInterface
Overwrite this if the LineFormatter is not a good default for your handler.
Return values
FormatterInterfacegetResource()
protected
getResource() : resource|null
Return values
resource|nullpfsockopen()
Wrapper to allow mocking
protected
pfsockopen() : resource|false
Return values
resource|falseprocessRecord()
Processes a record.
protected
processRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
- $record : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>resetProcessors()
protected
resetProcessors() : void
streamGetMetadata()
Wrapper to allow mocking
protected
streamGetMetadata() : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|boolstreamSetChunkSize()
Wrapper to allow mocking
protected
streamSetChunkSize() : int|bool
Tags
Return values
int|boolstreamSetTimeout()
Wrapper to allow mocking
protected
streamSetTimeout() : bool
Tags
Return values
boolwrite()
Connect (if necessary) and write to the socket
protected
write(array<string|int, mixed> $record) : void
Parameters
- $record : array<string|int, mixed>
buildContent()
private
buildContent(array<string|int, mixed> $record) : string
Parameters
- $record : array<string|int, mixed>
Tags
Return values
stringbuildHeader()
private
buildHeader(string $content) : string
Parameters
- $content : string
Return values
stringconnect()
private
connect() : void
connectIfNotConnected()
private
connectIfNotConnected() : void
createSocketResource()
private
createSocketResource() : void
setSocketTimeout()
private
setSocketTimeout() : void
setStreamChunkSize()
private
setStreamChunkSize() : void
validateTimeout()
private
validateTimeout(float $value) : void
Parameters
- $value : float
writeToSocket()
private
writeToSocket(string $data) : void
Parameters
- $data : string
writingIsTimedOut()
private
writingIsTimedOut(int $sent) : bool
Parameters
- $sent : int