SaveOptionsBuilder
extends ArrayObject
in package
uses
AssociationsNormalizerTrait
OOP style Save Option Builder.
Use a normal array for options instead.
This allows you to build options to save entities in a OOP style and helps you to avoid mistakes by validating the options as you build them.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Constructor.
- associated() : $this
- Set associated options.
- atomic() : $this
- Sets the atomic option.
- checkExisting() : $this
- Set check existing option.
- checkRules() : $this
- Option to check the rules.
- guard() : $this
- Set the guard option.
- parseArrayOptions() : $this
- Takes an options array and populates the option object with the data.
- set() : $this
- Setting custom options.
- toArray() : array<string, mixed>
- validate() : $this
- Set the validation rule set to use.
- _associated() : void
- Checks that the associations exists recursively.
- _checkAssociation() : void
- Checks if an association exists.
- _normalizeAssociations() : array<string|int, mixed>
- Returns an array out of the original passed associations list where dot notation is transformed into nested arrays so that they can be parsed by other routines
Properties
$_options
Options
protected
array<string, mixed>
$_options
= []
$_table
Table object.
protected
Table
$_table
Methods
__construct()
Constructor.
public
__construct(Table $table[, array<string, mixed> $options = [] ]) : mixed
Parameters
- $table : Table
-
A table instance.
- $options : array<string, mixed> = []
-
Options to parse when instantiating.
associated()
Set associated options.
public
associated(array<string|int, mixed>|string $associated) : $this
Parameters
- $associated : array<string|int, mixed>|string
-
String or array of associations.
Return values
$thisatomic()
Sets the atomic option.
public
atomic(bool $atomic) : $this
Parameters
- $atomic : bool
-
Atomic or not.
Return values
$thischeckExisting()
Set check existing option.
public
checkExisting(bool $checkExisting) : $this
Parameters
- $checkExisting : bool
-
Guard the properties or not.
Return values
$thischeckRules()
Option to check the rules.
public
checkRules(bool $checkRules) : $this
Parameters
- $checkRules : bool
-
Check the rules or not.
Return values
$thisguard()
Set the guard option.
public
guard(bool $guard) : $this
Parameters
- $guard : bool
-
Guard the properties or not.
Return values
$thisparseArrayOptions()
Takes an options array and populates the option object with the data.
public
parseArrayOptions(array<string, mixed> $array) : $this
This can be used to turn an options array into the object.
Parameters
- $array : array<string, mixed>
-
Options array.
Tags
Return values
$thisset()
Setting custom options.
public
set(string $option, mixed $value) : $this
Parameters
- $option : string
-
Option key.
- $value : mixed
-
Option value.
Return values
$thistoArray()
public
toArray() : array<string, mixed>
Return values
array<string, mixed>validate()
Set the validation rule set to use.
public
validate(string $validate) : $this
Parameters
- $validate : string
-
Name of the validation rule set to use.
Return values
$this_associated()
Checks that the associations exists recursively.
protected
_associated(Table $table, array<string|int, mixed> $associations) : void
Parameters
- $table : Table
-
Table object.
- $associations : array<string|int, mixed>
-
An associations array.
_checkAssociation()
Checks if an association exists.
protected
_checkAssociation(Table $table, string $association) : void
Parameters
- $table : Table
-
Table object.
- $association : string
-
Association name.
Tags
_normalizeAssociations()
Returns an array out of the original passed associations list where dot notation is transformed into nested arrays so that they can be parsed by other routines
protected
_normalizeAssociations(array<string|int, mixed>|string $associations) : array<string|int, mixed>
Parameters
- $associations : array<string|int, mixed>|string
-
The array of included associations.
Return values
array<string|int, mixed> —An array having dot notation transformed into nested arrays