Original file: src/Fsm/Data/ReplayTransitionsRequest.php
The ReplayTransitionsRequest.php file defines the ReplayTransitionsRequest class, which serves as a Data Transfer Object (DTO) designed for handling requests to replay Finite State Machine (FSM) transitions. This class validates and structures the input parameters necessary for reconstructing the state deterministically. By ensuring that the inputs are valid Eloquent model classes, IDs, and column names, it helps maintain the integrity of state transformations in the application.
stringstringstringpublic function __construct(
string|array $modelClass,
string $modelId = '',
string $columnName = '',
)
The constructor initializes the ReplayTransitionsRequest instance, populating the properties based on the parameters provided. It also handles the conversion of associative array keys from snake_case to camelCase, preparing the data for easier manipulation.
modelClass: This parameter can accept either a string representing the model class name or an associative array containing the properties of the class. If an array is provided, it should be in an associative format.modelId (optional): A string representing the unique identifier of the model instance. Defaults to an empty string.columnName (optional): A string representing the name of the column associated with FSM transitions. Defaults to an empty string.The constructor performs the following actions:
$modelClass is an associative array. If true, it prepares the attributes for further processing.Dto class with the appropriately structured data.$modelClass is a string, it directly populates the DTO properties and calls the parent constructor.public function rules(): array
The rules method defines the validation rules that the properties of the ReplayTransitionsRequest must adhere to. It is essential for ensuring that all required data is correctly formatted and that the modelClass provided is a legitimate Eloquent model.
array<string, array<int, string|callable>>modelClass
class_exists().Illuminate\Database\Eloquent\Model to confirm it is an Eloquent model.modelId
columnName
These rules enforce data integrity and help prevent runtime errors by ensuring that the request contains valid information before further processing.
This documentation serves as a guide for developers engaging with the ReplayTransitionsRequest class, ensuring they understand its purpose, functionality, and structure within the codebase. For further details, refer to the associated classes and methods that interact with this DTO.
How can I help you explore Laravel packages today?