Typing observer.

Runs on load or save, and ensures the correct data type of your ORM object properties.

 Methods

Make sure the orm config is loaded

_init() 

Get notified of an event

orm_notify(\Orm\Model $instance, string $event) 

Parameters

$instance

\Orm\Model

$event

string

Converts DB bool values to PHP bool value

type_bool_from_int(bool $var) : int

Parameters

$var

bool

value

Returns

int

Converts boolean input to 1 or 0 for the DB

type_bool_to_int(bool $var) : int

Parameters

$var

bool

value

Returns

int

Decimal post-treater, converts any number to a decimal representation

type_decimal_after(mixed $var, array $settings, array $matches) : float

Parameters

$var

mixed

value to typecast

$settings

$matches

Exceptions

\Orm\InvalidContentType

Returns

float

Decimal pre-treater, converts a decimal representation to a float

type_decimal_before(mixed $var, $settings) : float

Parameters

$var

mixed

value to typecast

$settings

Exceptions

\Orm\InvalidContentType

Returns

float

decrypt the input

type_decrypt(string $var) : mixed

Parameters

$var

string

value

Returns

mixed

Returns the encrypted input

type_encrypt(mixed $var, array $settings) : string

Parameters

$var

mixed

value

$settings

array

any options to be passed

Exceptions

\Orm\InvalidContentType

Returns

string

Casts to float when necessary

type_float_after(mixed $var) : float

Parameters

$var

mixed

value to typecast

Exceptions

\Orm\InvalidContentType

Returns

float

Casts float to string when necessary

type_float_before(mixed $var, $settings) : float

Parameters

$var

mixed

value to typecast

$settings

Exceptions

\Orm\InvalidContentType

Returns

float

Casts to int when necessary and checks if within max values

type_integer(mixed $var, array $settings) : int

Parameters

$var

mixed

value to typecast

$settings

array

any options to be passed

Exceptions

\Orm\InvalidContentType

Returns

int

Decodes the JSON

type_json_decode(string $var, $settings) : mixed

Parameters

$var

string

value

$settings

Returns

mixed

JSON encodes the input

type_json_encode(mixed $var, array $settings) : string

Parameters

$var

mixed

value

$settings

array

any options to be passed

Exceptions

\Orm\InvalidContentType

Returns

string

Returns the serialized input

type_serialize(mixed $var, array $settings) : string

Parameters

$var

mixed

value

$settings

array

any options to be passed

Exceptions

\Orm\InvalidContentType

Returns

string

Value post-treater, converts a comma-delimited string into an array

type_set_after(mixed $var) : array

Parameters

$var

mixed

value

Returns

array

Value pre-treater, deals with array values, and handles the enum type

type_set_before(mixed $var, array $settings) : string

Parameters

$var

mixed

value

$settings

array

any options to be passed

Exceptions

\Orm\InvalidContentType

Returns

string

Casts to string when necessary and checks if within max length

type_string(mixed $var, array $settings) : string

Parameters

$var

mixed

value to typecast

$settings

array

any options to be passed

Exceptions

\Orm\InvalidContentType

Returns

string

Takes a DB timestamp and converts it into a Date object

type_time_decode(string $var, array $settings) : \Fuel\Core\Date

Parameters

$var

string

value

$settings

array

any options to be passed

Returns

Takes a Date instance and transforms it into a DB timestamp

type_time_encode(\Fuel\Core\Date $var, array $settings) : int | string

Parameters

$var

\Fuel\Core\Date

value

$settings

array

any options to be passed

Exceptions

\Orm\InvalidContentType

Returns

intstring

Unserializes the input

type_unserialize(string $var) : mixed

Parameters

$var

string

value

Returns

mixed

Typecast a single column value based on the model properties for that column

typecast(string $column, string $value, string $settings, $event_type) : mixed

Parameters

$column

string

name of the column

$value

string

value

$settings

string

column settings from the model

$event_type

Exceptions

\Orm\InvalidContentType

Returns

mixed

 Properties

 

<p>types of events to act on and whether they are pre- or post-database</p>

$events : array

 

<p>regexes for db types with the method(s) to use, optionally pre- or post-database</p>

$regex_methods : array

 

<p>db type mappings</p>

$type_mappings : array

 

<p>db data types with the method(s) to use, optionally pre- or post-database</p>

$type_methods : array

 

$use_locale

$use_locale