\Inhere\Console\ConcernSimpleEventTrait

Class SimpleEventStaticTrait

Summary

Methods
Properties
Constants
on()
once()
fire()
off()
hasEvent()
isOnce()
isSupportedEvent()
getSupportEvents()
setSupportEvents()
getEvents()
countEvents()
No public properties found
No constants found
No protected methods found
$supportedEvents
N/A
No private methods found
$events
$eventHandlers
N/A

Properties

$supportedEvents

$supportedEvents : array

set the supported events, if you need.

if it is empty, will allow register any event.

Type

array

$events

$events : array

registered Events

Type

array — [ 'event' => bool, // is once event ]

$eventHandlers

$eventHandlers : array

events and handlers

Type

array — [ 'event' => callable, // event handler ]

Methods

on()

on(  $event, callable  $handler, boolean  $once = false) 

register a event handler

Parameters

$event
callable $handler
boolean $once

once()

once(  $event, callable  $handler) 

register a once event handler

Parameters

$event
callable $handler

fire()

fire(string  $event, mixed  ...$args) : boolean

trigger event

Parameters

string $event
mixed $args variadic

Returns

boolean

off()

off(  $event) : boolean

remove event and it's handlers

Parameters

$event

Returns

boolean

hasEvent()

hasEvent(  $event) : boolean

Parameters

$event

Returns

boolean

isOnce()

isOnce(  $event) : boolean

Parameters

$event

Returns

boolean

isSupportedEvent()

isSupportedEvent(string  $event) : boolean

check $name is a supported event name

Parameters

string $event

Returns

boolean

getSupportEvents()

getSupportEvents() : array

Returns

array

setSupportEvents()

setSupportEvents(array  $supportedEvents) 

Parameters

array $supportedEvents

getEvents()

getEvents() : array

Returns

array

countEvents()

countEvents() : integer

Returns

integer