Anchor
in package
Leaf Security Module --------------------------------- Simple to use security based utility methods
Tags
Table of Contents
Properties
Methods
- config() : mixed
- Manage config for leaf anchor
- deepGet() : mixed
- Get an item or items from an array of data.
- deepGetDot() : mixed
- Deep get an item or items from an array of data using dot notation.
- deepSetDot() : mixed
- Deep set an item or items in an array of data using dot notation.
- deepUnsetDot() : mixed
- Deep unset an item or items in an array of data using dot notation.
- errors() : array<string|int, mixed>
- generateToken() : string
- Generate a token for identifying your application
- sanitize() : mixed
- Escape malicious characters
- toBool() : bool
- Convert string to boolean. Created due to inconsistencies in PHP's boolval and (bool)
Properties
$config
protected
static mixed
$config
= ['secret' => '@nkor_leaf$0Secret!!', 'secretKey' => 'X-Leaf-CSRF-Token', 'except' => [], 'methods' => ['POST', 'PUT', 'PATCH', 'DELETE'], 'messages.tokenNotFound' => 'Token not found.', 'messages.tokenInvalid' => 'Invalid token.', 'onError' => null]
$errors
protected
static mixed
$errors
= []
Methods
config()
Manage config for leaf anchor
public
static config([array<string|int, mixed>|null $config = null ]) : mixed
Parameters
- $config : array<string|int, mixed>|null = null
-
The config to set
deepGet()
Get an item or items from an array of data.
public
static deepGet(array<string|int, mixed> $dataSource[, string|array<string|int, mixed> $item = null ]) : mixed
Parameters
- $dataSource : array<string|int, mixed>
-
An array of data to search through
- $item : string|array<string|int, mixed> = null
-
The items to return
deepGetDot()
Deep get an item or items from an array of data using dot notation.
public
static deepGetDot(array<string|int, mixed> $dataSource[, string|array<string|int, mixed> $item = null ]) : mixed
Parameters
- $dataSource : array<string|int, mixed>
-
An array of data to search through
- $item : string|array<string|int, mixed> = null
-
The items to return
deepSetDot()
Deep set an item or items in an array of data using dot notation.
public
static deepSetDot(array<string|int, mixed> $dataSource, string|array<string|int, mixed> $item[, mixed $value = null ]) : mixed
Parameters
- $dataSource : array<string|int, mixed>
-
An array of data to search through
- $item : string|array<string|int, mixed>
-
The items to set
- $value : mixed = null
-
The value to set
deepUnsetDot()
Deep unset an item or items in an array of data using dot notation.
public
static deepUnsetDot(mixed $dataSource, mixed $item) : mixed
Parameters
- $dataSource : mixed
- $item : mixed
errors()
public
static errors() : array<string|int, mixed>
Return values
array<string|int, mixed>generateToken()
Generate a token for identifying your application
public
static generateToken([int $strength = 16 ]) : string
Parameters
- $strength : int = 16
-
Number of random characters to attach to token
Return values
stringsanitize()
Escape malicious characters
public
static sanitize(mixed $data) : mixed
Parameters
- $data : mixed
-
The data to sanitize.
toBool()
Convert string to boolean. Created due to inconsistencies in PHP's boolval and (bool)
public
static toBool(string $value) : bool
Parameters
- $value : string
-
The value to convert