# CRUDlex\Entity

class `Entity`

  Represents a single set of data in field value pairs like the row in a database. Depends of course on the {@see AbstractData} implementation being used. With this objects, the data is passed arround and validated.

  property `definition`

    protected

    The {@see EntityDefinition} defining how this entity looks like.

  property `entity`

    protected

    Holds the key value data of the entity.

  `toType`($value, $type)

    Converts a given value to the given type.

    Parameters: | $value (mixed) – the value to convert $type (string) – the type to convert to like ‘integer’ or ‘float’
    Returns: | mixed the converted value

  `__construct`(EntityDefinition $definition)

    Constructor.

    Parameters: | $definition (EntityDefinition) – the definition how this entity looks

  `set`($field, $value)

    Sets a field value pair of this entity.

    Parameters: | $field (string) – the field $value (mixed) – the value

  `getRaw`($field)

    Gets the raw value of a field no matter what type it is. This is usefull for input validation for example.

    Parameters: | $field (string) – the field
    Returns: | mixed null on invalid field or else the raw value

  `get`($field)

    Gets the value of a field in its specific type.

    Parameters: | $field (string) – the field
    Returns: | mixed null on invalid field, an integer if the definition says that the type of the field is an integer, a boolean if the field is a boolean or else the raw value

  `getDefinition`()

    Gets the entity definition.

    Returns: | EntityDefinition the definition

  `populateViaRequest`(Request $request)

    Populates the entities fields from the requests parameters.

    Parameters: | $request (Request) – the request to take the field data from