Captcha uses Container
Captcha Utility
Attributes
- #[AllowDynamicProperties]
Table of Contents
Methods
| enabled() | Checks if a form is enabled for captcha validation |
| get() | Retrieve an instance of the captcha |
| getAvailable() | Lists all available captchas on the system |
| getOptions() | Fetches the default options for the captcha |
| validate() | Validates the response of the captcha |
| getFromContainer() | Fetch an item from the container |
Methods
enabled()
Checks if a form is enabled for captcha validation
public
static enabled(string $form) : bool
Parameters
- $form : string
-
The name of the form
Return values
bool —True if the form has captcha enabled, false otherwise
get()
Retrieve an instance of the captcha
public
static get([string $captcha = null ][, array<string|int, mixed> $options = [] ]) : CaptchaInterface
Parameters
- $captcha : string = null
-
The name of the captcha class to initialize
- $options : array<string|int, mixed> = []
-
The options to be used with the captcha
Return values
CaptchaInterfacegetAvailable()
Lists all available captchas on the system
public
static getAvailable() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of stdClass objects representing available catpchas
getOptions()
Fetches the default options for the captcha
public
static getOptions([string $captcha = null ]) : array<string|int, mixed>
Parameters
- $captcha : string = null
-
The name of the captcha class to fetch the options
Return values
array<string|int, mixed> —An array containing the default options for the captcha
validate()
Validates the response of the captcha
public
static validate(CaptchaInterface $captcha[, array<string|int, mixed> $post = [] ]) : bool
Parameters
- $captcha : CaptchaInterface
-
An instance of the captcha to validate
- $post : array<string|int, mixed> = []
-
An array containing the posted data
Return values
bool —True if the provided response for the captcha is valid, false otherwise
getFromContainer()
Fetch an item from the container
protected
getFromContainer(string $service) : mixed
Parameters
- $service : string
-
The name of the service from the container to fetch
Return values
mixed —The service if found, otherwise null