abstract class Type (View source)

The Type interface.

Constants

ID

INTID

CUSTOMID

BOOL

BOOLEAN

INT

INTEGER

FLOAT

STRING

DATE

KEY

TIMESTAMP

BINDATA

BINDATAFUNC

BINDATABYTEARRAY

BINDATAUUID

BINDATAUUIDRFC4122

BINDATAMD5

BINDATACUSTOM

FILE

HASH

COLLECTION

INCREMENT

OBJECTID

RAW

Methods

mixed
convertToDatabaseValue(mixed $value)

Converts a value from its PHP representation to its database representation of this type.

mixed
convertToPHPValue(mixed $value)

Converts a value from its database representation to its PHP representation of this type.

closureToMongo()

No description

closureToPHP()

No description

static 
registerType(string $name, string $class)

Register a new type in the type map.

static Type
getType(string $type)

Get a Type instance.

static Type
getTypeFromPHPVariable(mixed $variable)

Get a Type instance based on the type of the passed php variable.

static 
convertPHPToDatabaseValue($value)

No description

static 
addType(string $name, string $className)

Adds a custom type to the type map.

static boolean
hasType(string $name)

Checks if exists support for a type.

static 
overrideType(string $name, string $className)

Overrides an already defined type to use a different implementation.

static array
getTypesMap()

Get the types array map which holds all registered types and the corresponding type class

__toString()

No description

Details

mixed convertToDatabaseValue(mixed $value)

Converts a value from its PHP representation to its database representation of this type.

Parameters

mixed $value The value to convert.

Return Value

mixed The database representation of the value.

mixed convertToPHPValue(mixed $value)

Converts a value from its database representation to its PHP representation of this type.

Parameters

mixed $value The value to convert.

Return Value

mixed The PHP representation of the value.

closureToMongo()

closureToPHP()

static registerType(string $name, string $class)

Register a new type in the type map.

Parameters

string $name The name of the type.
string $class The class name.

static Type getType(string $type)

Get a Type instance.

Parameters

string $type The type name.

Return Value

Type $type

Exceptions

InvalidArgumentException

static Type getTypeFromPHPVariable(mixed $variable)

Get a Type instance based on the type of the passed php variable.

Parameters

mixed $variable

Return Value

Type $type

Exceptions

InvalidArgumentException

static convertPHPToDatabaseValue($value)

Parameters

$value

static addType(string $name, string $className)

Adds a custom type to the type map.

Parameters

string $name Name of the type. This should correspond to what getName() returns.
string $className The class name of the custom type.

Exceptions

MappingException

static boolean hasType(string $name)

Checks if exists support for a type.

Parameters

string $name Name of the type

Return Value

boolean TRUE if type is supported; FALSE otherwise

static overrideType(string $name, string $className)

Overrides an already defined type to use a different implementation.

Parameters

string $name
string $className

Exceptions

MappingException

static array getTypesMap()

Get the types array map which holds all registered types and the corresponding type class

Return Value

array $typesMap

__toString()