Fr3nch13/CakePHP Utilities

FloatType extends BaseType
in package
implements BatchCastingInterface

Float type converter.

Use to convert float/decimal data between PHP and the database types.

Table of Contents

Interfaces

BatchCastingInterface
Denotes type objects capable of converting many values from their original database representation to php values.

Properties

$numberClass  : string
The class to use for representing number objects
$_name  : string|null
Identifier name for this type
$_useLocaleParser  : bool
Whether numbers should be parsed using a locale aware parser when marshalling string inputs.

Methods

__construct()  : mixed
Constructor
getBaseType()  : string|null
Returns the base type name that this class is inheriting.
getName()  : string|null
Returns type identifier name for this object.
manyToPHP()  : array<string, mixed>
Returns an array of the values converted to the PHP representation of this type.
marshal()  : string|float|null
Marshals request data into PHP floats.
newId()  : mixed
Generate a new primary key value for a given type.
toDatabase()  : float|null
Convert integer data into the database format.
toPHP()  : float|null
Casts given value from a database type to a PHP equivalent.
toStatement()  : int
Get the correct PDO binding type for float data.
useLocaleParser()  : $this
Sets whether to parse numbers passed to the marshal() function by using a locale aware parser.
_parseValue()  : float
Converts a string into a float point after parsing it using the locale aware parser.

Properties

$numberClass

The class to use for representing number objects

public static string $numberClass = \Cake\I18n\Number::class

$_name

Identifier name for this type

protected string|null $_name

$_useLocaleParser

Whether numbers should be parsed using a locale aware parser when marshalling string inputs.

protected bool $_useLocaleParser = false

Methods

__construct()

Constructor

public __construct([string|null $name = null ]) : mixed
Parameters
$name : string|null = null

The name identifying this type

getBaseType()

Returns the base type name that this class is inheriting.

public getBaseType() : string|null
Tags
inheritDoc
Return values
string|null

The base type name that this class is inheriting.

getName()

Returns type identifier name for this object.

public getName() : string|null
Tags
inheritDoc
Return values
string|null

The type identifier name for this object.

manyToPHP()

Returns an array of the values converted to the PHP representation of this type.

public manyToPHP(array<string|int, mixed> $values, array<string|int, mixed> $fields, DriverInterface $driver) : array<string, mixed>
Parameters
$values : array<string|int, mixed>

The original array of values containing the fields to be casted

$fields : array<string|int, mixed>

The field keys to cast

$driver : DriverInterface

Object from which database preferences and configuration will be extracted.

Tags
inheritDoc
Return values
array<string, mixed>

marshal()

Marshals request data into PHP floats.

public marshal(mixed $value) : string|float|null
Parameters
$value : mixed

The value to convert.

Return values
string|float|null

Converted value.

newId()

Generate a new primary key value for a given type.

public newId() : mixed
Tags
inheritDoc
Return values
mixed

A new primary key value.

toDatabase()

Convert integer data into the database format.

public toDatabase(mixed $value, DriverInterface $driver) : float|null
Parameters
$value : mixed

The value to convert.

$driver : DriverInterface

The driver instance to convert with.

Return values
float|null

toPHP()

Casts given value from a database type to a PHP equivalent.

public toPHP(mixed $value, DriverInterface $driver) : float|null
Parameters
$value : mixed

The value to convert.

$driver : DriverInterface

The driver instance to convert with.

Tags
throws
CakeException
Return values
float|null

toStatement()

Get the correct PDO binding type for float data.

public toStatement(mixed $value, DriverInterface $driver) : int
Parameters
$value : mixed

The value being bound.

$driver : DriverInterface

The driver.

Return values
int

useLocaleParser()

Sets whether to parse numbers passed to the marshal() function by using a locale aware parser.

public useLocaleParser([bool $enable = true ]) : $this
Parameters
$enable : bool = true

Whether to enable

Return values
$this

_parseValue()

Converts a string into a float point after parsing it using the locale aware parser.

protected _parseValue(string $value) : float
Parameters
$value : string

The value to parse and convert to an float.

Return values
float

        
On this page

Search results