BasicPrompt extends Collection implements CorporatePrompt
A basic implementation of a prompt that extends Laravel's Collection and implements the CorporatePrompt Contract.
This class provides methods to encode prompt data into JSON and decode JSON strings back into prompt data, as well as a method to set the prompt text.
Table of Contents
Interfaces
- CorporatePrompt
- Defines the contract for prompts that are compatible with LaravelNeuro Networking features.
Methods
- getPrompt() : string
- Gets the prompt text.
- promptDecode() : static
- Decodes a JSON-encoded prompt string into a BasicPrompt instance.
- promptEncode() : string
- Encodes the prompt data into a JSON string.
- setPrompt() : $this
- Sets the prompt text.
- decoder() : void
- Decodes a JSON-encoded prompt string and stores the result in the collection.
- encoder() : string
- Encodes the prompt stored in the collection into a JSON string.
Methods
getPrompt()
Gets the prompt text.
public
getPrompt() : string
Return values
string —$this Returns the current prompt string.
promptDecode()
Decodes a JSON-encoded prompt string into a BasicPrompt instance.
public
static promptDecode(string $promptString) : static
This static method creates a new instance of BasicPrompt, decodes the provided JSON string, and sets the prompt data accordingly.
Parameters
- $promptString : string
-
JSON-encoded prompt string.
Return values
static —A new instance of BasicPrompt with the decoded prompt data.
promptEncode()
Encodes the prompt data into a JSON string.
public
promptEncode() : string
This method utilizes the internal encoder to transform the prompt stored in the collection into a JSON representation.
Return values
string —JSON-encoded prompt data.
setPrompt()
Sets the prompt text.
public
setPrompt(string $prompt) : $this
Stores the provided prompt text in the collection under the key "prompt".
Parameters
- $prompt : string
-
The prompt text.
Return values
$this —Returns the current instance for method chaining.
decoder()
Decodes a JSON-encoded prompt string and stores the result in the collection.
protected
decoder(string $promptString) : void
The decoded value is stored under the "prompt" key.
Parameters
- $promptString : string
-
The JSON-encoded prompt string.
encoder()
Encodes the prompt stored in the collection into a JSON string.
protected
encoder() : string
Ensures that a "prompt" key exists in the collection before encoding.
Return values
string —The JSON-encoded representation of the prompt.