mirror of
https://github.com/NamelessMC/Nameless
synced 2026-08-18 06:29:04 -04:00
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Represents a class-based event.
|
|
*
|
|
* @package NamelessMC\Events
|
|
* @author Aberdeener
|
|
* @version 2.3.0
|
|
* @license MIT
|
|
*/
|
|
abstract class AbstractEvent
|
|
{
|
|
/**
|
|
* Convert the class name to the event name.
|
|
* Example: UserDeletedEvent -> userDeleted.
|
|
*
|
|
* @return string The name of the subclass, without the "Event" suffix
|
|
*/
|
|
public static function name(): string
|
|
{
|
|
return lcfirst(str_replace('Event', '', static::class));
|
|
}
|
|
|
|
/**
|
|
* Get the description of the event.
|
|
*
|
|
* @return string The description of the event
|
|
*/
|
|
public static function description(): string
|
|
{
|
|
return static::name();
|
|
}
|
|
|
|
/**
|
|
* Determine whether to hide this hook from users in the StaffCP, some events should be private.
|
|
*
|
|
* @return bool Whether to hide this hook from users in the StaffCP
|
|
*/
|
|
public static function internal(): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Get the parameters of the event.
|
|
* Parameters are assumed to be public properties of the event class.
|
|
*
|
|
* @return array The parameters of the event
|
|
*/
|
|
final public function params(): array
|
|
{
|
|
return get_object_vars($this);
|
|
}
|
|
}
|