Class TypeFactory

Factory for building database type classes.

Namespace: Cake\Database

Properties summary

  • $_builtTypes protected static
    \Cake\Database\TypeInterface[]

    Contains a map of type object instances to be reused if needed.

  • $_types protected static
    array<string,string>

    List of supported database types. A human readable identifier is used as key and a complete namespaced class name as value representing the class that will do actual type conversions.

Method Summary

  • build() public static

    Returns a Type object capable of converting a type identified by name.

  • buildAll() public static

    Returns an arrays with all the mapped type objects, indexed by name.

  • clear() public static

    Clears out all created instances and mapped types classes, useful for testing

  • getMap() public static

    Get mapped class name for given type or map array.

  • map() public static

    Registers a new type identifier and maps it to a fully namespaced classname.

  • set() public static

    Set TypeInterface instance capable of converting a type identified by $name

  • setMap() public static

    Set type to classname mapping.

Method Detail

build() public static

build(string $name)

Returns a Type object capable of converting a type identified by name.

Parameters

string $name

type identifier

Returns

\Cake\Database\TypeInterface

Throws

InvalidArgumentException
If type identifier is unknown

buildAll() public static

buildAll()

Returns an arrays with all the mapped type objects, indexed by name.

Returns

\Cake\Database\TypeInterface[]

clear() public static

clear()

Clears out all created instances and mapped types classes, useful for testing

getMap() public static

getMap(?string $type)

Get mapped class name for given type or map array.

Parameters

string|null $type optional

Type name to get mapped class for or null to get map array.

Returns

string[]|string|null

Configured class name for given $type or map array.

map() public static

map(string $type, string $className)

Registers a new type identifier and maps it to a fully namespaced classname.

Parameters

string $type

Name of type to map.

string $className

The classname to register.

set() public static

set(string $name, \Cake\Database\TypeInterface $instance)

Set TypeInterface instance capable of converting a type identified by $name

Parameters

string $name

The type identifier you want to set.

\Cake\Database\TypeInterface $instance

The type instance you want to set.

setMap() public static

setMap(array $map)

Set type to classname mapping.

Parameters

string[] $map

List of types to be mapped.

Property Detail

$_builtTypes protected static

Contains a map of type object instances to be reused if needed.

Type

\Cake\Database\TypeInterface[]

$_types protected static

List of supported database types. A human readable identifier is used as key and a complete namespaced class name as value representing the class that will do actual type conversions.

Type

array<string,string>

© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.0/class-Cake.Database.TypeFactory.html