MockEvents
        
        extends Events
    
    
            
            in package
            
        
    
    
    
Events
Table of Contents
Constants
- PRIORITY_HIGH = 10
- PRIORITY_LOW = 200
- PRIORITY_NORMAL = 100
Properties
- $files : array<int, string>
- A list of found files.
- $initialized : bool
- Flag to let us know if we've read from the Config file(s) and have all of the defined events.
- 
    $listeners
    
                         : array<string, array{0: bool, 1: list, 2: list }> 
- The list of listeners.
- $performanceLog : array<int, array{start: float, end: float, event: string}>
- Stores information about the events for display in the debug toolbar.
- $simulate : bool
- If true, events will not actually be fired.
Methods
- getEventsFile() : array<int, string>
- getFiles() : array<int, string>
- Returns the files that were found/loaded during this request.
- 
    getListeners()
    
                                 : array<string, array{0: bool, 1: list, 2: list }> 
- getPerformanceLogs() : array<int, array{start: float, end: float, event: string}>
- Getter for the performance log records.
- getSimulate() : bool
- initialize() : void
- Ensures that we have a events file ready.
- listeners() : array<int, callable(mixed): mixed>
- Returns an array of listeners for a single event. They are sorted by priority.
- on() : void
- Registers an action to happen on an event. The action can be any sort of callable:
- removeAllListeners() : void
- Removes all listeners.
- removeListener() : bool
- Removes a single listener from an event.
- setFiles() : void
- Sets the path to the file that routes are read from.
- simulate() : void
- Turns simulation on or off. When on, events will not be triggered, simply logged. Useful during testing when you don't actually want the tests to run.
- trigger() : bool
- Runs through all subscribed methods running them one at a time, until either: a) All subscribers have finished or b) a method returns false, at which point execution of subscribers stops.
- unInitialize() : void
Constants
PRIORITY_HIGH
    public
        mixed
    PRIORITY_HIGH
    = 10
    
    
    
    
PRIORITY_LOW
    public
        mixed
    PRIORITY_LOW
    = 200
    
    
    
    
PRIORITY_NORMAL
    public
        mixed
    PRIORITY_NORMAL
    = 100
    
    
    
    
Properties
$files
A list of found files.
        protected
        static    array<int, string>
    $files
     = []
    
    
    
    
    
$initialized
Flag to let us know if we've read from the Config file(s) and have all of the defined events.
        protected
        static    bool
    $initialized
     = false
    
    
    
    
    
$listeners
The list of listeners.
        protected
        static    array<string, array{0: bool, 1: list, 2: list}>  
    $listeners
     = []
    
    
    
    
    
$performanceLog
Stores information about the events for display in the debug toolbar.
        protected
        static    array<int, array{start: float, end: float, event: string}>
    $performanceLog
     = []
    
    
    
    
    
$simulate
If true, events will not actually be fired.
        protected
        static    bool
    $simulate
     = false
        Useful during testing.
Methods
getEventsFile()
    public
                    getEventsFile() : array<int, string>
    Return values
array<int, string>getFiles()
Returns the files that were found/loaded during this request.
    public
            static        getFiles() : array<int, string>
    Return values
array<int, string>getListeners()
    public
                    getListeners() : array<string, array{0: bool, 1: list, 2: list}>  
    Return values
array<string, array{0: bool, 1: listgetPerformanceLogs()
Getter for the performance log records.
    public
            static        getPerformanceLogs() : array<int, array{start: float, end: float, event: string}>
    Return values
array<int, array{start: float, end: float, event: string}>getSimulate()
    public
                    getSimulate() : bool
    Return values
boolinitialize()
Ensures that we have a events file ready.
    public
            static        initialize() : void
    listeners()
Returns an array of listeners for a single event. They are sorted by priority.
    public
            static        listeners(string $eventName) : array<int, callable(mixed): mixed>
    Parameters
- $eventName : string
Return values
array<int, callable(mixed): mixed>on()
Registers an action to happen on an event. The action can be any sort of callable:
    public
            static        on(string $eventName, callable(mixed): mixed $callback[, int $priority = self::PRIORITY_NORMAL ]) : void
    Events::on('create', 'myFunction'); // procedural function Events::on('create', ['myClass', 'myMethod']); // Class::method Events::on('create', [$myInstance, 'myMethod']); // Method on an existing instance Events::on('create', function() }); // Closure
Parameters
- $eventName : string
- $callback : callable(mixed): mixed
- $priority : int = self::PRIORITY_NORMAL
removeAllListeners()
Removes all listeners.
    public
            static        removeAllListeners([string|null $eventName = null ]) : void
    If the event_name is specified, only listeners for that event will be removed, otherwise all listeners for all events are removed.
Parameters
- $eventName : string|null = null
removeListener()
Removes a single listener from an event.
    public
            static        removeListener(string $eventName, callable(mixed): mixed $listener) : bool
    If the listener couldn't be found, returns FALSE, else TRUE if it was removed.
Parameters
- $eventName : string
- $listener : callable(mixed): mixed
Return values
boolsetFiles()
Sets the path to the file that routes are read from.
    public
            static        setFiles(array<int, string> $files) : void
    Parameters
- $files : array<int, string>
simulate()
Turns simulation on or off. When on, events will not be triggered, simply logged. Useful during testing when you don't actually want the tests to run.
    public
            static        simulate([bool $choice = true ]) : void
    Parameters
- $choice : bool = true
trigger()
Runs through all subscribed methods running them one at a time, until either: a) All subscribers have finished or b) a method returns false, at which point execution of subscribers stops.
    public
            static        trigger(string $eventName, mixed ...$arguments) : bool
    Parameters
- $eventName : string
- $arguments : mixed
Return values
boolunInitialize()
    public
                    unInitialize() : void